Teaser 2526: [Lucky dates]
From The Sunday Times, 20th February 2011 [link] [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?
This puzzle was originally published with no title.
[teaser2526]






Jim Randell 8:04 am on 29 April 2025 Permalink |
I am assuming that “this century” means the 21st century (which started on 2001-01-01).
And “the sum of the six digits of Orla’s wedding date” refers to the sum of date expressed as “DD/MM/YY” (i.e. using the final 2 digits of the year, rather than indicating that Orla’s wedding date is of the form “D/M/YYYY”).
This Python program runs in 67ms. (Internal runtime is 9.0ms).
from datetime import (date, timedelta) from enigma import (irange, repeat, inc, dsum, catch, printf) # increment date (<d>, <m>, <y>) by <i> months def incmonth(d, m, y, i=1): m += i while m > 12: m -= 12 y += 1 return catch(date, y, m, d) # consider dates in the 21st century for Orla's wedding for d1 in repeat(inc(timedelta(days=1)), date(2001, 1, 1)): if d1.year > 2009: break # calculate the day of the week wd = d1.isoweekday() valid = lambda x: x is not None and x.isoweekday() == wd # calculate the digit sum of the date (6 digits) (d, m, y) = (d1.day, d1.month, d1.year) n = dsum(d) + dsum(m) + dsum(y % 100) # consider a date <n> months in advance d2 = incmonth(d, m, y, n) if not valid(d2): continue if not (d2.year - d1.year > 1): continue # and check no intervening date would do if any(valid(incmonth(d, m, y, i)) for i in irange(1, n - 1)): continue # output solution printf("Orla = {d1}, Enya = {d2} [{n} months later]")Solution: Orla’s wedding day was: Wednesday, 31st December 2008.
The next (Wednesday, 31st) occurs on: Wednesday, 31st March 2010, and so this is Enya’s wedding day.
Enya’s wedding day occurs 15 months after Orla’s, and the sum of the digits in Orla’s date expressed as: 31/12/08 is 15.
If we were to use an 8-digit format for the dates (e.g. “DD/MM/YYYY” or “YYYY-MM-DD”), we can get a solution of:
LikeLike
Frits 12:32 pm on 30 April 2025 Permalink |
from enigma import SubstitutedExpression from datetime import date # check date format and possible other checks def check(AB, CD, EF, extra=False): try: wd = date(2000 + EF, CD, AB).weekday() except ValueError: return False if extra: # check if in the next year there are any dates with day number AB # on the same weekday as Orla's for m in range(1, 13): try: if date(2000 + EF + 1, m, AB).weekday() == wd: return False except ValueError: continue return True # the alphametic puzzle p = SubstitutedExpression( [ # Orla : AB-CD-EF Enya: AB-GH-IJ (dd-mm-yy) "AB < 32", "CD < 13", # Enya married months later but not in the following year "(sd := A + B + C + D + E + F) > 24 - CD", # check validity of Orla's date and that Enya could not be married # in the following year "check(AB, CD, EF, 1)", "IJ <= 11", # 2011 # Enya could not be married in the following year "IJ > EF + 1", # Enya married months later, the actual number of months being the sum # of the six digits of Orla's wedding date "sd - 12 * (IJ - EF) + CD = GH", "0 < GH < 13", # check validity of Enya's date "check(AB, GH, IJ)", # Enya married on the same day of the week as Orla "date(2000 + EF, CD, AB).weekday() == date(2000 + IJ, GH, AB).weekday()" ], answer="(AB, CD, 2000 + EF)", d2i=dict([(k, "ICGE") for k in range(2, 4)] + [(k, "AICGE") for k in range(4, 10)]), distinct="", s2d=dict(E=0), env=dict(date=date, check=check), reorder=0, verbose=0, # use 256 to see the generated code ) # print answers for ans in p.answers(): print(f"answer: {'-'.join(str(x) for x in ans)}")LikeLike