Sunday Times Teaser 2526
by H Bradley and C Higgins
Published: 20 February 2011 (link)
Orla was married in this century, on her lucky day of the week, and her twin sister Enya’s lucky-number day of the month. Enya told Orla on that big day that she intended her own wedding to be on the same lucky day of the week and lucky-number day of the month. She realised that it could not be in the same year as Orla’s, but Orla added that Enya could not be married in the following year, either. Enya married months later, the actual number of months being the sum of the six digits of Orla’s wedding date.
What was Orla’s wedding date?
One Comment
Leave one →
-
Brian Gladman permalink12345678910111213141516171819202122232425262728293031323334353637383940414243444546from datetime import date, timedeltafrom calendar import monthrange# Orla's wedding is this century (set to# last date of previous to allow for the# increment)orla = date(day=31, month=12, year=1999)# Orla's wedding had occured before the date# that the puzzle was publishedwhile orla < date(day=11, month=2, year=2011):orla += timedelta(days=1)# the sum of the digits in Orla's datesum_digits = sum(map(int, str(orla.day)+ str(orla.month) + str(orla.year % 100)))# now consider Enya's wedding dateenya_month, enya_year = orla.month, orla.year# which is after Orla's by not more than a number# of months equal to the Orla's date's digit sumfor months in range(1, sum_digits + 1):# advance enya's date a month at a time, looking# for a day of the month AND a day of the week# that match Orla'senya_year = enya_year + (1 if enya_month == 12 else 0)enya_month = (enya_month % 12) + 1# we only need to consider months in which Orla and# Enya's day of the month is validif orla.day <= monthrange(enya_year, enya_month)[1]:enya = date(day=orla.day, month=enya_month, year=enya_year)# check for a weekday matchif enya.weekday() == orla.weekday():# the first match for both the day of the month and# the weekday cannot occur in Orla's wedding year# or in the year afterif enya_year < orla.year + 2 or months != sum_digits:breakprint("Orla married on {} (Enya married in {}).".format(orla.strftime("%A %d %B %Y"), enya.strftime("%B %Y")))