Enigmatic Code

Programming Enigma Puzzles

Enigma 1043: Grandad

From New Scientist #2199, 14th August 1999 [link]

My late grandfather was born on a fine summer Sunday, several decades ago. His sixth, twelfth and eighteenth birthdays were also on Sundays, as was his birthday in 1994.

How old would Grandad have been on his birthday in 1999 if he had survived?


2 responses to “Enigma 1043: Grandad

  1. Jim Randell 24 September 2018 at 7:28 am

    This Python program runs in 80ms.

    Run: [ @repl.it ]

    import datetime
    from collections import Counter
    from enigma import irange, printf
    # find (day, month) pairs that are Sundays (weekday=6) in 1994
    def generate():
      # 1994-01-02 was a Sunday
      d = datetime.date(1994, 1, 2)
      week = datetime.timedelta(days=7)
      while d.year == 1994:
        yield (d.day, d.month)
        d += week
    # record possible ages
    r = Counter()
    for (d, m) in generate():
      # find years where the birthday falls on a Sunday
      years = list(y for y in irange(1854, 1993) if datetime.date(y, m, d).weekday() == 6)
      # now look for possible birth years
      for y in years:
        # check 6th, 12th and 18th birthdays
        if all(y + n in years for n in (6, 12, 18)):
          age = 1999 - y
          printf("[birthdate = {y:04d}-{m:02d}-{d:02d}, 1999 age = {age}]")
          r[age] += 1
    # output solutions
    for (k, v) in r.items():
      printf("1999 age = {k} [{v} solutions]")

    Solution: Grandad would have celebrated his 107th birthday in 1999.

    Grandad was born in 1892.

    There are 43 possible dates:

    March: 6th, 13th, 20th, 27th
    April: 10th, 17th, 24th
    May: 1st, 8th, 15th, 22nd, 29th
    June: 5th, 12th, 19th, 26th
    July: 3rd, 10th, 17th, 24th, 31st
    August: 7th, 14th, 21st, 28th
    September: 4th, 11th, 18th, 25th
    October: 2nd, 9th, 16th, 23rd, 30th
    November: 6th, 13th, 20th, 27th
    December: 4th, 11th, 18th, 25th

    If we assume “summer” limits the months to June, July, August (northern hemisphere), then these possibilities are narrowed down to 13 possible dates.

    If we assume “summer” limits the months to December, January, February (southern hemisphere), then these possibilities are narrowed down to the 4 possible dates in December. So Grandad could have been born on Christmas Day in Australia.

    But all possible dates are in 1892, so it is not really necessary to narrow these down further.

    His 6th birthday was in 1898, his 12th in 1904, his 18th in 1910, and 1994 was his 102nd birthday.

  2. Hugh Casement 24 September 2018 at 7:52 am

    1900 was not a leap year, of course.
    His birthdays fell on a Sunday in 1898, 1904, 1910, 1921, 1927, 1932, 1938, 1949, 1955, 1960, 1966, 1977, 1983, 1988.   Somehow I suspect that was the last: there would be no need to assume he lived to 102.

Leave a Comment

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.

%d bloggers like this: