Teaser 3065: Members of the jury
From The Sunday Times, 20th June 2021 [link]
A jury had twelve members, all with different ages (at least 20 but not more than 65), except that two were twins with a common age over 40. The average age was a prime number. A counsel objected to one of the members and he was replaced by another with the result that the average age was reduced to another prime number. Between the two juries, there were twelve different ages and they formed a progression with a common difference (e.g., 1, 4, 7, 10, 13, etc. or 6, 13, 20, 27, 34, etc.,). None of the individuals had a perfect square age, and the replacement jury still included both twins.
How old were the twins?
[teaser3065]
Jim Randell 2:38 pm on 18 June 2021 Permalink |
This Python program runs in 53ms.
Run: [ @replit ]
Solution: The twins are 41.
The sequence of ages for both juries are all those ages between 26 and 59 in steps of 3.
The ages of the original jury are:
The 59 year old is then replaced by a 35 year old:
One way to test your program is to remove the constraint that there are no squares. Without this condition you should find 10 different answers for the age of the twins.
LikeLiked by 1 person
Tony Brooke-Taylor 12:05 pm on 19 June 2021 Permalink |
Similar routine but with a bit less trial and error, so marginally quicker
LikeLiked by 1 person
Jim Randell 10:20 am on 20 June 2021 Permalink |
The [[
Primes
]] class in the enigma.py library implements a prime sieve, so you can use the following to avoid having to include the code in your program, but still posting runnable code.And it might be worth placing longer comments on the line above the code, as horizontal space is limited in replies.
LikeLike
Jim Randell 10:57 am on 20 June 2021 Permalink |
@Tony: It’s an interesting approach.
Here’s a version using a similar idea, but calculates the separation of the replacement/replaced pair in the progression from the difference between the prime means, and then looks for suitable candidates, from which the repeated age can be determined:
There is only one candidate pair of prime ages, and only one of the potential replacement/replaced pairings gives a duplicate age greater than 40.
(And a bit more analysis fixes the values of the common difference, the mean ages, and the difference between the replaced and replacement ages).
LikeLike
Brian Gladman 10:27 am on 20 June 2021 Permalink |
A nice approach, Tony, which I ‘stole’ here. For those who want to run your code, here is a one line replacement for line one:
LikeLike
GeoffR 1:27 pm on 20 June 2021 Permalink |
Hi Tony,
I have re-formatted your code to PEP8, which can easily be done under the Wingware IDE for Python,
using Source/Reformatting from the main menu – hope you don’t mind, but it does make code much
easier to read and appreciate by others. Have also replaced end of line comments as separate comments, as suggested by Jim. An interesting solution.
https://wingware.com/downloads
LikeLike
Tony Brooke-Taylor 12:04 pm on 26 June 2021 Permalink |
Thanks all for your comments. I apologise for my continued struggles making my code readable in these replies. I’ll have a look at the Wingware IDE.
LikeLike
Hugh Casement 11:34 am on 27 June 2021 Permalink |
With the same sequence the twins could have been aged 32, 35, or 38 (had those been allowed), still with the same two average ages. I found no other sequences that work, assuming no square ages .
LikeLike