Sunday Times Teaser 2738 – Prime Day for the Irish
by H Bradley and C Higgins
Published: 15 March 2015 (link)
St Patrick’s Day is March 17 and it is a prime day in many ways: What number month? 3; What number day? 17; How many letters in “March”? 5; How many days in March? 31.
I asked Pat the same questions about his birthday this year — but I simply asked whether the four answers were prime or not. When he had told me he said “now, if I told you its day of the week this year, you should be able to work out my birthday.” Then, without me actually being told the day, I was indeed able to work out his birthday.
What is his birthday?
One Comment
Leave one →
-
Brian Gladman permalink123456789101112131415161718192021222324252627282930313233343536373839from datetime import datefrom calendar import month_name, monthrangefrom collections import defaultdictfrom number_theory import Primes# dates are in this yearyear = 2015# store possible birthday dates indexed first on the# four truth values and then on the day of the weekd1 = defaultdict(lambda: defaultdict(list))for month in range(1, 13):# compile the three truth properties for the monthmonth_length = monthrange(year, month)[1]t3 = tuple(x in Primes() for x in(month, len(month_name[month]), month_length))for day in range(1, month_length + 1):# find the day of the weekdow = date(year, month, day).weekday()# add the truth value for the day of the month and store resultsd1[t3 + (day in Primes(),)][dow].append((day, month))d2 = defaultdict(list)# now consider each of the sixteen combinations of truth propertiesfor t4, d_dm in d1.items():# and look for days of the week that lead to a unique datefor dow, l_bd in d_dm.items():if len(l_bd) == 1:d2[t4].append(l_bd[0])# now look for a set of truth properties with only one unique datefor t4, l_bd in d2.items():if len(l_bd) == 1:print('His birthday is {} {}.'.format( l_bd[0][0], month_name[l_bd[0][1]]))