Sunday Times Teaser 2776 – Winning Months
by Graham Smithers
Published: 6 December 2015 (link)
I have won three Premium Bond prizes and noted the number of non-winning months between my first and second wins, and also the number between my second and third wins. Looking at the letters in the spelling of the months, I have also noted the difference between the numbers of letters in the months of my first and second wins, and also the difference between those of the months of my second and third wins. All four numbers noted were the same, and if you knew that number then it would be possible to work out the months of my wins.
What (in order of the wins) were those three months?
One Comment
Leave one →
-
Brian Gladman permalink12345678910111213141516171819202122232425262728from collections import defaultdictmonths = ('January', 'February', 'March', 'April', 'May', 'June', 'July','August', 'September', 'October', 'November', 'December' )# for listing all the possible triples of months for each gap lengthgap_to_months = defaultdict(list)# the maximum gap is six (the maximum difference in month name length)for gap in range(1, 7):# the first month index (0 .. 11)for i in range(12):# the three month namesm = m1, m2, m3 = [months[(i + j * (gap + 1)) % 12] for j in range(3)]# the differences in the lengths of the month names for the first and# second wins and for the second and third wins must both equal gapif abs(len(m1) - len(m2)) == abs(len(m2) - len(m3)) == gap:gap_to_months[gap] += [m]# one value of gap must lead to a unique solutionfor g, months_list in gap_to_months.items():if len(months_list) == 1:s = ' and '.join(months_list[0]).replace(' and', ',', 1)print('The wins were in {}.'.format(s))