Sunday Times Teaser 2557 – The Legacy
by Graham Smithers
Published: 25 September 2011 (link)
In my will I have set aside a five-figure sum of pounds for charity — a group of four animal charities and a group of seven children’s charities. This five- figure sum consists of five consecutive non-zero digits, not in numerical order. On my death this legacy is to be divided equally between these charities. But I have left it to my executors’ discretion to choose to divide it instead equally among the charities in just one of the groups. each donation will be a whole number of pounds, whichever course they take.
What is the five-figure sum?
One Comment
Leave one →
-
Brian Gladman permalink1234567891011121314from itertools import permutationsfrom functools import reduce# the start value of the five digit sequencefor i5 in range(1, 6):# permute the 5 digits to give possible legacy valuesfor d5 in permutations(range(i5, i5 + 5)):legacy = reduce(lambda x, y : 10 * x + y, d5)# we need a value that will divide exactly by# 4, 7 and 11if not any(legacy % x for x in (4, 7, 11)):print('The legacy is {}{}.'.format(u'\xA3', legacy))