Teaser 3170: Time to admire the adverts
From The Sunday Times, 25th June 2023 [link] [link]
George and Martha use a local underground station, which has up and down escalators and an adjacent 168-step staircase. Martha always uses the escalator. George, being the fitness fanatic, always uses the stairs. In olden times, he could keep up with her while climbing or descending at seven steps per second. But now he can only ascend at N steps per second and descend at N + 1 steps per second, N being a whole number. They start together at the bottom and go up and down continually, losing negligible time in turning. Interestingly, at some point after they have both been all the way up and down, but before ten minutes have elapsed, Martha overtakes George precisely half-way up or half-way down.
After how many seconds does this happen?
[teaser3170]









Jim Randell 4:55 pm on 23 June 2023 Permalink |
Presumably N is between 1 and 6.
This Python program considers possible values, generating the times for Martha and George at the halfway mark, and then looking for times when Martha is overtaking George.
We use rational numbers to avoid loss of precision in floating point comparisons.
It runs in 64ms. (Internal runtime is 140µs).
Run: [ @replit ]
from enigma import (Rational, irange, printf) Q = Rational() # generate times at halfway (less than T) -> t def times(up, dn, H=84, T=600): # go halfway up t = Q(H, up) # go half up/dn (or half dn/up) to return to halfway inc = t + Q(H, dn) while t < T: yield t t += inc # generate M's times M = dict((t, m) for (m, t) in enumerate(times(7, 7))) # consider possible N values for N in irange(1, 6): # generate G's times for (g, t) in enumerate(times(N, N + 1)): # look for times when they meet if g < 2: continue m = M.get(t) if m is None: continue # we are interested in when they are going the same direction if m % 2 != g % 2: continue # output solution printf("N={N}: t={t}s [g={g} m={m}]")Solution: After 588 seconds.
i.e. after 9 minutes, 48 seconds.
George can only manage 1 step/s ascending and 2 steps/s descending.
At that time George has been up the stairs 2.5 times (each ascent taking 168s) and down 2 times (each descent taking 84s, so the total time is 2.5×168 + 2×84 = 588s).
Martha has been up the stairs 12.5 times and down 12 times (each ascent and descent takes 24s, so the total time is 12.5×24 + 12×24 = 588s).
Manually:
Martha travels at a constant 7 steps per second, so she is at halfway at the following times (in seconds):
i.e. the odd multiples of 12, less than 600 (= 10 minutes).
The first two elements are discarded (as M must have completed one full up and down).
So she is going up on [60, 108, 156, …, 588] and down on [84, 132, 180, …, 564].
As multiples of 12 these are:
George takes N steps/s going up and (N + 1) steps/s going down so, he is halfway at:
When N = 1, G’s halfway points are separated by 84 + 42 = 126:
And as multiples of 12 these are:
Only the first and fifth are odd multiples of 12, and the first two elements are discounted as G must have completed one full up and down.
So only the fifth element for G is permissible, and as it is in an odd position, G is on his way up.
And 49 also appears on M’s up list, so this gives an answer to the puzzle.
And there are no further solutions for N = 2 .. 6.
LikeLike
Frits 6:15 pm on 23 June 2023 Permalink |
NS = 168 # number of staircase steps # one cycle: going up and down # walk for less than 10 minutes and check halfway points for Martha for t in range(12, 600, 24): # determine the direction Martha was going directionM = "u" if t % 48 == 12 else "d" for N in range(1, 7): # times for George to walk up and down u, d = NS / N, NS / (N + 1) r = t % (u + d) # time left after cycles have been completed # George must have been halfway if r not in {u / 2, u + d / 2}: continue # determine the direction George was going directionG = "u" if r < u else "d" if directionG != directionM: continue print("answer: after", t, "seconds")LikeLike
Frits 2:25 pm on 26 June 2023 Permalink |
71 iterations.
# work with tenths of seconds to avoid fractional inaccuracies # when dividing by 5 # T = time in tenths of seconds to walk all staircase steps # if you take 1 step a second T = 10 * 168 # possible answers, Martha must have gone up and down at least twice answers = set(range(1080, 6000, 240)) # consider possible N values for N in range(1, 7): # times in tenths of second for George to walk up and down u, d = T // N, T // (N + 1) ud, half_ud = u + d, (u + d) // 2 up = 1 # toggle for up/down t = ud + u // 2 # check George's times at halfway points while t < 6000: # for Martha to overtake George also check their directions if t in answers and ((t % 480) == 120) == up: print("answer: after", t // 10, "seconds") t += half_ud up = 1 - upLikeLike
Jim Randell 10:10 am on 28 June 2023 Permalink |
@Frits: Yes, calculating G’s halfway times and then checking to see when one matches a halfway time for M only considers 71 cases (because when G is slow, he doesn’t reach halfway many times in the 10 minutes).
And I think in general it is also a good idea not to rely on strict equality of floats.
LikeLike