Sunday Times Teaser 2791 – Four-Square Family
by Susan Bricket
Published: 20 March 2016 (link)
My four sons are all under 20 and just one of them is a teenager. Their ages (or, more precisely, the squares of their ages) have some remarkable properties. Firstly, two years ago the square of one of their ages equalled the sum of the squares of the other three ages. Secondly, this year the sum of the squares of two of their ages equals the sum of the squares of the other two ages.
What, in increasing order, are their ages?
One Comment
Leave one →
-
Brian Gladman permalink12345678910111213141516from itertools import combinations_with_replacement# the ages of the three youngest sonsfor a, b, c in combinations_with_replacement(range(2, 13), 3):# calculate the teenager's age from the sum of the squares# of the ages of the other three two years agot = (a - 2) ** 2 + (b - 2) ** 2 + (c - 2) ** 2d = int(t ** 0.5 + 0.5) + 2if (d - 2) ** 2 == t and 12 < d < 20:# now equate the sums of the squares of the ages of pairs of sonsif a ** 2 + d ** 2 == b ** 2 + c ** 2:print('Their ages are {}, {}, {} and {}.'.format(a, b, c, d))