Brain-Teaser 737: Regular as clockwork
From The Sunday Times, 31st August 1975 [link]
Our old watchmaker works weekdays 9:30am to 5pm as regular as, well, clockwork. I recently took there to be regulated two “8-day” striking clocks – the sort which fully wound will go nearly 8 days before stopping; they were keeping different times and each was wrong by an exact number of minutes per day, i.e. less than an hour in either case.
He immediately wound the clocks fully, set them to the right time (which was an exact number of minutes after the hour) and put them up on a shelf for observation.
The next Monday, when he went to take down the clocks to start regulating them, he found both of them just starting to strike 8 o’clock simultaneously, which was some hours plus an exact number of minutes past the correct time.
What day and exact time was it when he originally set them?
This puzzle is included in the book The Sunday Times Book of Brain-Teasers: Book 1 (1980). The puzzle text above is taken from the book.
[teaser737]
Jim Randell 9:24 am on 22 April 2021 Permalink |
A clock that gained 1 hour a day would take 12 days (or 12.5 days clock time) to show the right time (but actually be 12 hours fast). Similarly a clock that lost 1 hour a day would take 12 days (or 11.5 day clock time) to show the right time (but actually be 12 hours slow).
And the clocks we are interested would run out long before they achieved this.
But if we look at both the clocks it would only take 6 days for them to both show the same time (i.e. have a difference of 12 hours between them).
This would be achievable with the clocks in the puzzle.
If the clocks were set at 2 o’clock on Tuesday afternoon, then at 2pm on the following Monday they would both read 8 o’clock (one of them having gained 6 hours, and the other having lost 6 hours). So the puzzle seems reasonable, and the solution is probably close to this, although the clocks we have to consider must only gain or lost at most 59 minutes a day.
We are interested in when the difference between the clocks is a multiple of 12 hours. For clocks that show a difference of d minutes per day, the time t at which they show a difference that is a multiple k of 12 hours is:
We know d is in the range [1, 118], t is less than 8 days. So:
Hence k = 1 and d is in the range [91, 118], and t is an exact number of minutes.
This Python program examines possible (t, d) values, and eliminates t values that make impossible to finish on a Monday. It then looks for gain/loss values for the clocks that give an exact number of minutes when they are both showing the same time, give a start time that is during working hours. It runs in 47ms.
Run: [ @replit ]
from enigma import (irange, divisors_pairs, div, sprintf, fdiv, printf) # working in minutes R = 12 * 60 # repeat period of clocks D = 24 * 60 # minutes in a day W = 7 * D # minutes in a week # work hours (9:30am - 5:00pm, Mon(= 0) to Fri(= 4) work = list([570 + x, 1020 + x] for x in irange(0, 4 * D, step=D)) # check if time is during work hours def check(t): t %= W return any(x <= t <= y for (x, y) in work) def fmt(m): (d, m) = divmod(m % W, D) day = ("Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sun")[d] (h, m) = divmod(m, 60) return sprintf("{day} {h:02d}:{m:02d}") # find valid (d, t) pairs for (d, t) in divisors_pairs(R * D, every=1): if d < 91: continue if d > 118: break # calculate start window, for a finish during Monday's work hours a = (work[0][0] - t) % W b = (work[0][1] - t) % W if not (check(a) or check(b)): continue # look for times separated by d that give integer start times for x in irange(59, -59, step=-1): y = x - d if y < -59: break # calculate the time differences dy = div(t * (D + y), D) if dy is None: continue # clock Y is slow and showing 8am on Monday (= 480) # find out when it was set t0 = (480 - dy) % W if not check(t0): continue # output solution printf("start = {t0} [end = {end}; d={d}m t={t:g}d; x={x}m y={y}m]", t0=fmt(t0), end=fmt(t0 + t), t=fdiv(t, D))Solution: The clocks were originally set on Monday at 9:48am.
The difference in the time the clocks show is 100 minutes per day, so after 7.2 days they are different by 720 minutes = 12 hours.
One clock gains 45 minutes per day, and the other loses 55 minutes per day.
So after 7.2 days the fast clock has gained 324 minutes (so it thinks it has been running for 7.425 days), and the slow clock has lost 396 minutes (so it thinks it has been running for 6.925 days).
The slow clock is showing 8am, but it is actually 6h36m later than that, i.e. 2:36pm.
And the fast clock is showing 8pm, but it is actually 5h24m earlier than that, i.e. 2:36pm.
So the clocks are showing the same time at 2:36pm on Monday (which is during working hours), so they must have been set 7.2 days before this, i.e. one week and 4h48m earlier = 9:48am the previous Monday (also during working hours).
LikeLike
Frits 10:26 pm on 22 April 2021 Permalink |
from enigma import div # between Friday 17:00 - Monday 09:30 there are 3870 minutes # between Monday 09:30 - Monday 17:00 there are 3870 + 6660 minutes # assume 3870 + M minutes have gone by # number of days passed = (3870 + M) / 1440 # loop over clock minutes running too slow or too fast for X in range(1, 60): for W in range(1, 60): # for variables x, w use values -1, 1 for sign of resp. numbers X and W for x in [-1, 1]: for w in [-1, 1]: # avoid duplicate solutions if x * X >= w * W: continue # clocks strike at the same time # 480 + X * no_days (08:00) or 1200 - X * no_days (20:00) # (3 * x + 7) * 120 - x * X * (3870 + M) / 1440 == \ # (3 * w + 7) * 120 - w * W * (3870 + M) / 1440", # calculate minutes M = div(518400 * (w - x) - (w * W - x * X) * 3870, w * W - x * X) if M is None: continue # maximum range Monday 09:30 - Monday 17:00 if M > 6660: continue # gain has to be a whole number gain = div(X * (3870 + M), 1440) if gain is None: continue # time = real time (in minutes) the clocks strikes at the same time # "480 + gain" or "1200 - gain" time = (3 * x + 7) * 120 - x * gain # clocks were set (3870 + M) / 1440 days before # 9:30 = 570 minutes, 17:00 = 1020 minutes if not(570 <= (1440 + time - (3870 + M)) % 1440 <= 1020): continue days = ["Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sun"] h = (time - (3870 + M) % 1440) // 60 m = (time - (3870 + M) % 1440) % 60 d = (3870 + M) // 1440 day = days[7 - d] print(f"day = {day}, exact time {h}:{m}")LikeLike