Enigmatic Code

Programming Enigma Puzzles

Enigma 1685: A noted eccentric

From New Scientist #2852, 18th February 2012 [link]

My whimsical uncle tells me that he goes to his study at a certain time every day, but doesn’t say when. On Sundays when he arrives, he winds each of his two eight-day clocks and sets them to the correct time. One of the clocks gains an exact number of minutes each day, and the other loses the same, so the mean of the times is correct through the week.

He also tells me that on three days during a previous week (Sundays being excluded), as he entered the study he jotted down the time from one or other of the clocks, and he now produces the resulting slips of paper with the times 8:56, 9:11 and 9:20 written on them. These times are not necessarily in the order in which they were written down, nor do we know which clock is associated with which timing. Nevertheless, my uncle tells me I can deduce that he noted the time on a particular day of the week.

Which day was that?

[enigma1685]

Advertisements

One response to “Enigma 1685: A noted eccentric

  1. jimrandell 15 February 2012 at 8:57 pm

    The following Python program runs in 27ms.

    # the difference between the clock times must all be multiples of the number
    # of minutes the clocks gain/lose a day
    
    # since the differences are:
    #  9m = 3x3
    # 15m = 3x5
    # 24m = 2x2x2x3
    # it follows that the clocks must gain/lose 3 minutes a day
    
    from itertools import combinations, product
    
    # convert day ordinals to text
    DAY = ['Su', 'Mo', 'Tu', 'We', 'Th', 'Fr', 'Sa']
    
    # keep track of potential solutions
    days = set(range(1, 7))
    
    # there are three days involved
    for (d1, d2, d3) in combinations(range(1, 7), 3):
      # and two clocks, which either gain (+1) or lose (-1)
      for (c1, c2, c3) in product((1, -1), repeat=3):
        # so the three times are
        t = sorted((c1*d1, c2*d2, c3*d3))
        # in order they must go: 0m, +15m, +24m
        if list(x - min(t) for x in t) != [0, 5, 8]: continue
    
        # keep days common to all solutions
        days.intersection_update((d1, d2, d3))
    
        # print the days and the offets from the real entry time
        for i in range(3):
          print("{day}: {d:+3d}m".format(day=DAY[abs(t[i])], d=t[i]*3), end=", ")
        # and the real entry time itself
        t = 8*60 + 56 - t[0]*3
        print("time = {h}:{m:02d}".format(h=t//60, m=t%60))
    
    # what days are common to all solutions?
    print('SOLUTION', '=', '/'.join(DAY[x] for x in days))
    

    Solution: The time was noted on Tuesday.

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: