Enigmatic Code

Programming Enigma Puzzles

Enigma 1639: Square clocks

From New Scientist #2805, 26th March 2011 [link]

In, say, 5-clock arithmetic, counting runs from 1 to 5, but starts again at 1 when 6 is reached. So, in 5-clock arithmetic, 3 + 4 = 2 and so on. Anne, Brian and Cate have been investigating x-clock arithmetic, where x is 2 to 15 inclusive. They have each discovered a two-digit square which, expressed in their three different clocks, gives the same number y.

If I told you the value of y, you could tell me the value of the square and the three values of x they were considering.

NOTE: As stated the problem does not specify what the required solution is. There are three distinct solutions, and the question has no way of distinguishing which is the “right” one.

When the intended solution was published in the magazine it became clear that in order to arrive at that solution you needed to use standard modulo arithmetic, and not the variation explicitly given in the question. A clarification was later published, accepting the three solutions as the answer.

[enigma1639]

Advertisements

One response to “Enigma 1639: Square clocks

  1. jimrandell 11 December 2011 at 4:15 pm

    This Python program finds the three solutions in 32ms.

    If you want to find the originally intended solution, just change clock(x, n) to return x % n.

    from collections import defaultdict
    
    # find two digit squares
    squares = list(i * i for i in range(4, 10))
    
    clocks = range(2, 16)
    
    # clock arithmetic goes from 1..n (not 0..n-1) so we map 0 => n
    def clock(x, n):
      r = x % n
      return r if r > 0 else n
    
    x = defaultdict(list)
    for s in squares:
      r = tuple(clock(s, n) for n in clocks)
      d = dict()
      for y in set(r):
        n = r.count(y)
        if n != 3: continue
        d[y] = n
        x[y].append(s)
      print(s, r, d)
    
    for (y, s) in x.items():
      if len(s) > 1: continue
      s = s[0]
      c = tuple(n for n in clocks if clock(s, n) == y)
      print("y={y} => square={s} clocks={c}".format(y=y, s=s, c=c))
    

    Solution: There are three solutions: If y=2, then the square is 16, and the clocks are 2, 7 and 14. If y=3, then the square is 81, and the clocks are 3, 6 and 13. If y=6, then the square is 36, and the clocks are 6, 10 and 15.

    The originally intended solution (using normal modulo arithmetic), is y=4, the square is 49, and the clocks are 5, 9 and 15.

    It’s also worth noting that the original statement of the problem does have a unique solution if 4-digit squares are used instead of 2-digit squares. That solution is: y=5, the square is 9025, and the clocks are 5, 10, 11.

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 )

Twitter picture

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

Facebook photo

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

Google+ photo

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

Connecting to %s

%d bloggers like this: