Enigmatic Code

Programming Enigma Puzzles

Enigma 111: Time trouble

From New Scientist #1225, 28th May 1981 [link]

Enigma 111“What’s the time?” gasped Bulldog Drumstick, too groggy to have a clue.

“Something o’clock,” leered Sing Sing, “and now for a test of British intelligence. There is no guarantee that the clock is the right way up. There is no minute hand. The numbers have all been repainted, some or all of them wrong. If you can tell me the time, you can go free. If not the piranhas are peckish.”

“Be a sport and say how many numbers were repainted the same as before.”

“Never! If you knew that, you could deduce the time.”

Our hero then gave him a British uppercut and made his exit. But you, I am sure, would first announce the right time.

What is it?



One response to “Enigma 111: Time trouble

  1. Jim Randell 28 July 2013 at 9:02 am

    This Python program runs in 41ms.

    from collections import defaultdict
    from enigma import irange, printf
    # 0 represents 12
    numbers = [0, 6, 9, 4, 1, 5, 3, 7, 11, 10, 2, 8]
    # accumulate positions by number of correct digits
    r = defaultdict(list)
    # consider each position (clock rotated clockwise p positions)
    for p in irange(0, 11):
      # how many numbers would be correct?
      c = list(n for (i, n) in enumerate(numbers) if (i + p) % 12 == n)
      printf("[{p}: correct={c}]")
    # find unique possibilities
    for (c, ps) in r.items():
      if len(ps) != 1: continue
      p = ps[0]
      x = (12 if p == 0 else p)
      printf("time = {x} o'clock [position={p}, correct={c}]")

    Solution: The time is 1 o’clock.

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

%d bloggers like this: