Enigmatic Code

Programming Enigma Puzzles

Enigma 53: Calculating birthdays

From New Scientist #1196, 28th February 1980 [link]

“When where you born?” Jamie asked Camilla.

“I’ll tell you what,” she said, “I’ll write the date on your calculator as a five-figure number, made up of the date, month and last two digits of the year — for example, if it was St Valentine’s Day, 1963, I would put 14263. There we are. You see that I was born in the 1950s. How many days are there in my birthday’s month.”

“Thirty” replied Jamie confidently.

“That’s right. Now, do you see that if I were to divide the number formed by the last two digits by an odd, prime factor of the whole number the result would be a different factor of the whole number? Now I’ll multiply the whole number by that odd prime factor.”

“Why, that makes the six-figure date of my fourth birthday, and its year is 20 more than your birth-year!” exclaimed Jamie.

What was Jamie’s date of birth?

Note: As posed this puzzle seems to have no solutions. But by relaxing the condition on Camilla’s birth month having 30 days I was able to find a unique solution (which is the same as the published solution).

[enigma53]

3 responses to “Enigma 53: Calculating birthdays

  1. Jim Randell 2 February 2013 at 10:11 am

    Relaxing the condition of Camilla’s birth month having 30 days let me find a unique solution. The following Python code runs in 104ms.

    from enigma import irange, concat, factor, uniq, printf
    
    # 5-digit dates in the 50's; either: ddmyy or dmmyy
    for yy in irange(50, 59):
      for mm in irange(1, 12): # originally (4, 6, 9, 11):
        for dd in (irange(10, 30) if mm < 10 else irange(1, 9)):
          n = int(concat(dd, mm, yy))
          # find factors of n
          for f in uniq(factor(n)):
            if not(f < yy): break
            # factors must be odd
            if f == 2: continue
            # and should divide yy
            (d, r) = divmod(yy, f)
            if r > 0: continue
            # result is a different divisor of n
            if d == f or n % d > 0: continue
            # new number is 6 digit
            n2 = n * f
            if len(str(n2)) != 6: continue
            # and should look like a date 20 years on from yy
            (x, yy2) = divmod(n2, 100)
            if yy2 != yy + 20: continue
            (dd2, mm2) = divmod(x, 100)
            if not(0 < dd2 < 32 and 0 < mm2 < 13): continue
            # subtract 4 years to get Jamie's birth date
            yy2 -= 4
            printf("jamie={dd2}/{mm2}/{yy2} [camilla={dd}/{mm}/{yy}, {yy}/{f}={d}, {n}x{f}={n2}]")
    

    Solution: Jamie’s date of birth is 12th December 1971.

    Curiously in this “review” [“Enigmatters”, New Scientist #1329, 28th October 1982] of his own book (of which I have recently acquired a second-hand copy) Robert Eastaway, the setter of this Enigma, states:

    Perhaps the biggest blunder came in an Enigma entitled ‘Calculating birthdays’. The whole puzzle depended for its solution on April having 31 days. Under normal circumstances I would have relished sending the author responsible a sarcastic letter about how I’d been missing a day all these years… only being the author on this occasion it was not exactly appropriate.

    However the solution I found does not depend on April having 31 days. Instead it depends on February having 30 days.

    • Hugh Casement 30 August 2014 at 3:18 pm

      I found the wording somewhat confusing anyway. I feel it would have been clearer to say something like “As you see, the two-digit year has two prime factors, which are also factors of the complete number. I now multiply by one of those factors.” No need to state that they’re odd, because the only numbers I could find that produce valid dates 20 years on are some in 1952 multiplied by 11 (but 11 is not a factor of 52) and even dates (20th of the month onward) in January and February 1955 multiplied by 5. And the only one of those that is also a multiple of 11 is 24255. Or have I missed something?

      How anyone could think that either January or February has 30 days defies belief.
      Over the years, Eastaway built up quite a reputation!

      • Julian Gray 4 December 2015 at 2:13 pm

        I’m a late-comer to this Enigma and was frustrated yesterday not to find a solution and, perversely, delighted to discover from your comments that it wasn’t my fault. If only Jamie had said “Not thirty one” instead of “Thirty” we would all have got there first time.

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: