Sunday Times Teaser 2570 – Christmas Teaser
by Victor Bryant
Published: 25 December 2011 (link)
I asked my nine-year-old grandson Sam to set a Teaser for today’s special edition and the result was:
SAM SET NICE CHRISTMAS TEASER.
Those words are the result of taking five odd multiples of nine and consistently replacing digits by letters. Given that THREE is divisible by 3:
What is the 9-digit number CHRISTMAS?
One Comment
Leave one →
-
Brian Gladman permalink123456789101112131415161718192021222324252627282930313233343536373839404142from itertools import permutationsfrom functools import reducewords = ('SAM', 'SET', 'NICE', 'CHRISTMAS', 'TEASER', 'THREE')# since the five numbers are all odd, we can permute# the odd digits for their last lettersfor p in permutations((1, 3, 5, 7, 9)):# map letters to these digitsl2d = dict(zip('EMRST', p))# SAM is a multiple of 9SET = 100 * l2d['S'] + 10 * l2d['E'] + l2d['T']if SET % 9 == 0:# now permute the remaining digits for As1 = set(range(10)).difference(p)for A in s1:l2d['A'] = A# SAM is a multiple of 9SAM = 100 * l2d['S'] + 10 * A + l2d['M']if SET % 9 == 0:# now permute the remaining digts for the# remaining lettersfor q in permutations(s1.difference([A])):l2d.update(zip('CHIN', q))# C and N are leading digits so they are non-zeroif 0 not in (l2d['C'], l2d['N']):# evaluate the numeric values of the remaining wordsnbrs = [reduce(lambda x, y:10 * x + y,(l2d[s] for s in w)) for w in (words[2:])]# check that THREE is divisible by 3and the rest by 9if nbrs[-1] % 3 == 0 and all(x % 9 == 0 for x in nbrs[:-1]):print('Christmas is {}.'.format(nbrs[1]))