Teaser 2894: Time duality
From The Sunday Times, 11th March 2018 [link] [link]
After a good breakfast, Seb decided on 40 winks. He noted the time on his digital clock as he dozed off. When he woke up a little later that day, not fully alert, he saw the display reflected in a mirror and was amazed by how long he seemed to have slept. This was in fact 10 times the length of his nap. Next day, a similar thing happened: he fell asleep at the same time and slept a little less, but when he woke, the mirror led him to believe he had slept for 20 times as long as he had. (All times were whole numbers of minutes after midnight).
At what time did he fall asleep?
[teaser2894]
Jim Randell 9:16 am on 7 August 2019 Permalink |
We can find multiple solutions to this puzzle, depending on how the clock works.
The program examines the following three scenarios for a digital clock consisting of standard 7-segment digits, where the digits 0, 1 and 8 appear the same when mirrored, and the digits 2 and 5 appear as each other when mirrored.
Scenario 1: 24 hour clock, always displays 4 digits, reads from 00:00 – 23:59.
Scenario 2: 24 hour clock, leading zeros are suppressed on the hours, and no clear hour/minute separator, reads from 0:00 – 23:59.
Scenario 3: 12 hour clock, leading zeros are suppressed on the hours, and no clear hour/minute separator, reads from 12:00 – 11:59.
It runs in 125ms.
Run: [ @replit ]
from enigma import (defaultdict, cproduct, arg, irange, nsplit, div, sprintf, printf) # digit reflections X = None # 0 1 2 3 4 5 6 7 8 9 reflect = [ 0, 1, 5, X, X, 2, X, X, 8, X ] # format time t as hh:mm def fmt(t, hours=24): k = 0 while t < 0: k -= 1 t += hours * 60 while t > hours * 60: k += 1 t -= hours * 60 (h, m) = divmod(t, 60) return sprintf("{h:02d}:{m:02d} [{k:+d}]") # solve using digits function <digits> def solve(digits, hours=24): # record results by start time (in minutes), 10x or 20x rs = defaultdict(lambda: defaultdict(list)) # map display digits to possible times m = defaultdict(list) for t in irange(0, 24 * 60 - 1): m[digits(t)].append(t) # find sequences that have a reverse sequence for (s, t1s) in m.items(): r = tuple(reflect[d] for d in s[::-1]) if None in r or r == s: continue if r in m: t2s = m[r] for (t1, t2) in cproduct([t1s, t2s]): if t1 == t2: continue while t2 < t1: t2 += 24 * 60 d = t2 - t1 # find differences that give 9x or 19y x = div(d, 9) if x: t0 = t1 - x printf("[{t1} | {t2} = {d} min (9x {x}m), t0={t0}]", t1=fmt(t1, hours), t2=fmt(t2, hours), t0=fmt(t0, hours)) rs[t0][10].append((t1, t2)) y = div(d, 19) if y: t0 = t1 - y printf("[{t1} | {t2} = {d} min (19x {y}m), t0={t0}]", t1=fmt(t1, hours), t2=fmt(t2, hours), t0=fmt(t0, hours)) rs[t0][20].append((t1, t2)) # output solutions for (t0, d) in rs.items(): for ((t1a, t2a), (t1b, t2b)) in cproduct([d[10], d[20]]): if t1b < t1a: (ft0, ft1a, ft2a, ft1b, ft2b) = (fmt(x, hours) for x in (t0, t1a, t2a, t1b, t2b)) printf("10x = {ft0} - {ft1a} | {ft2a} / 20x = {ft0} - {ft1b} | {ft2b}") # digits displayed for time t in the different scenarios: # [1] four digits, 24 hours: 00:00 - 23:59 def digits1(t): (h, m) = divmod(t, 60) return nsplit(h % 24, 2) + nsplit(m, 2) # [2] three or four digits, 24 hours: 0:00 - 23:59, no clear separator def digits2(t): (h, m) = divmod(t, 60) return nsplit(h % 24) + nsplit(m, 2) # [3] three or four digits, 12 hours: 0:00 - 11:59, no clear separator def digits3(t): (h, m) = divmod(t, 60) return nsplit(h % 12 or 12) + nsplit(m, 2) types = { '1': [ digits1, "[type 1] 00:00 - 23:59", 24 ], '2': [ digits2, "[type 2] 0:00 - 23:59", 24 ], '3': [ digits3, "[type 3] 12:00 - 11:59", 12 ], } cmd = arg("123", 0) for k in sorted(types.keys()): if k not in cmd: continue (fn, t, h) = types[k] printf("{t}") solve(fn, hours=h) printf()We find the following solutions:
Scenario 1: 24 hour clock, always displays 4 digits, reads from 00:00 – 23:59.
This is probably the most reasonable expectation of the clock’s behaviour without further explanation.
But in both these solutions the second nap is less than half the length of the first nap, so it is a bit odd to say he slept “a little less” than the previous day.
Scenario 2: 24 hour clock, leading zeros are suppressed on the hours, and no clear hour/minute separator, reads from 0:00 – 23:59.
The 09:41 nap works the same, but the 09:21 nap does not as 10:20 when mirrored does not correspond to a displayable time.
This scenario has a unique solution, but the problem remains that the second nap is less than half the length of the first nap.
Scenario 3: 12 hour clock, leading zeros are suppressed on the hours, and no clear hour/minute separator, reads from 12:00 – 11:59.
And as it is a 12 hour clock this all works shifted on 12 hours, although perhaps 7:18pm is a little late to be having breakfast.
The problem here is that on day two when seeing the clock reading 2:18 Seb would probably think he had slept for 7 hours, not for 19 hours. However this is the best solution for sleeping “a little less” on the second day, and the puzzle text does say Seb was not fully alert when he read the clock.
Out of all these scenarios the one that best fits the puzzle text is Scenario 3:
This gives us a solution to the puzzle that Seb fell asleep on both days at 7:18am.
It is possible that the phrase “all times were whole numbers of minutes after midnight”, is meant to indicate that all the times mentioned (including the false mirrored times) are all supposed to fall within the same 24 hour day, in which case the 9:41am solution in Scenario 1 or Scenario 2 remain, and give a unique solution of 9:41am. This may be the setters intended solution.
But as there are multiple possible answers I have marked this puzzle as “flawed“.
The published solution is: “09:41am”.
LikeLiked by 1 person