Teaser 2819: An age-old problem
From The Sunday Times, 2nd October 2016 [link] [link]
Five men of different ages under fifty are celebrating their joint birthday in the pub. Alan’s age is the average of their five ages. When Bob is three times Alan’s age today, the sum of Alan’s and Colin’s ages will equal the sum of their five ages today. Furthermore, Derek will then be three times his age today, and Eric will be one year more than double Bob’s age today.
The landlord checked that the youngest of the five was allowed to buy alcohol.
Who is the youngest, and how old is he?
[teaser2819]







Jim Randell 10:50 am on 23 October 2019 Permalink |
The conditions in the puzzle text give us 4 equations in 5 variables:
If we set a value for one of the ages, then the other 4 ages are determined.
We can then look for a set of integer ages, where only the youngest member of the party is asked for proof of age.
I supposed the barman might ask anyone who looked 21 or younger for proof of age, and this gives a unique solution.
This Python program uses the [[
matrix.linear()]] solver from the enigma.py library to solve the equations. It runs in 148ms.Run: [ @repl.it ]
from enigma import irange, matrix, as_int, arg, printf # the constraints give the following four equations: # # 4A - B - C - D - E = 0 # 6A - 3B - D - E = 0 # 3A - B - 2D = 0 # 3A - 3B + E = 1 eqs = [ # A B C D E [ 4, -1, -1, -1, -1 ], # = 0 [ 6, -3, 0, -1, -1 ], # = 0 [ 3, -1, 0, -2, 0 ], # = 0 [ 3, -3, 0, 0, 1 ], # = 1 [ 1, 0, 0, 0, 0 ], # = A ] # age range for the men (min, max) m = arg( 1, 0, int) M = arg(49, 1, int) printf("[ages: min = {m}, max = {M}]") # choose a value for A for a in irange(m, M): # solve the equations for integers try: ss = tuple(as_int(x) for x in matrix.linear(eqs, [0, 0, 0, 1, a])) except ValueError: continue # discard any solutions with ages not in the required range if any(x < m or x > M for x in ss): continue # count how many are 21 or under? n = sum(x < 22 for x in ss) if n != 1: continue # output the solution s = min(zip(ss, "ABCDE")) (A, B, C, D, E) = ss printf("youngest={s[1]} age={s[0]} [A={A} B={B} C={C} D={D} E={E}]")Solution: Colin is the youngest. He is 20.
There are three sets of ages (between 1 and 49) that satisfy the equations:
In the first two sets more than one of the “men” is below the legal age to buy alcohol (18 in the UK), so the third set is the most likely answer. The youngest man is aged 20, and so could reasonably be asked for proof of age.
If we were to restrict the minimum age to 18 only the final set is possible. (And this remains true if we take the minimum age down as far as 13).
LikeLike
GeoffR 3:04 pm on 23 October 2019 Permalink |
LikeLike