Teaser 2776: Winning months
From The Sunday Times, 6th December 2015Â [link] [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?
[teaser2776]






Jim Randell 9:48 am on 18 February 2021 Permalink |
The largest difference in number of letters is 6 (“May” to “September”), so we don’t need to worry about time spans longer than this.
This Python program runs in 52ms.
Run: [ @repl.it ]
from enigma import filter_unique, unpack, irange, join, printf # month names (in English) months = ( 'January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December', ) # month lengths ls = set(len(x) for x in months) M = max(ls) - min(ls) # map (<n>, <month1>) -> <month2> # where month1 and month2 are separated by n months # and month2 length is different from month1 by n d = dict() for (m1, name) in enumerate(months): l1 = len(name) for n in irange(0, M): m2 = (m1 + n + 1) % 12 if abs(l1 - len(months[m2])) == n: d[(n, m1)] = m2 # now look for elements (n, m1) -> m2 where (n, m2) -> m3 rs = list() for ((n, m1), m2) in d.items(): m3 = d.get((n, m2), None) if m3 is not None: ms = tuple(months[i] for i in (m1, m2, m3)) rs.append((n, ms)) printf("[n={n}: {ms}]", ms=join(ms, sep=' -> ')) # find unambiguous solutions by n rs = filter_unique(rs, unpack(lambda n, ms: n)).unique # output solutions for (n, ms) in rs: printf("SOLUTION: n={n}, {ms}", ms=join(ms, sep=' -> '))Solution: The winning months are: February, July, December.
This is the only set of months such that each adjacent pair has 4 months between them, and also differ by 4 letters.
There are ambiguous solutions for values 1 and 5:
LikeLike