Brain-Teaser 39: [Simultaneous departures]
From The Sunday Times, 17th December 1961 [link]
Two train services run from my station day and night. Each train of each service is scheduled to leave a whole number of minutes after the previous one. I remarked to the station-master on the closeness of the two afternoon trains, 12:17 and 12:18. “Actually”, he replied, “there are two morning trains which leave simultaneously”.
At what time does this happen?
This puzzle was originally published with no title.
[teaser39]
Jim Randell 11:24 am on 11 July 2021 Permalink |
I think there is some ambiguity in this puzzle.
I supposed that there was only time per day that there was a train for each service leaving simultaneously, and that time was in the morning (i.e. between 00:00 and 11:59).
And also that the interval between trains on the same service must be at least 10 minutes (in order to make trains departing 1 minute apart an occurrence of note). Originally I assumed at least 5 minutes, but this gave me multiple solutions.
There are 24 × 60 = 1440 minutes in a day so the frequencies of the services must divide this.
This Python program runs in 59ms.
Run: [ @replit ]
from enigma import (irange, divisors, intersect, subsets, peek, printf) # times for a service, given a reference time <t> and frequency <d> times = lambda t, d: set(x % 1440 for x in irange(t, t + 1439, step=d)) # consider possible frequencies for the two services ds = (d for d in divisors(1440) if 9 < d < 1440) for (dA, dB) in subsets(ds, size=2, select="M"): # look for simultaneous times in both services ts = intersect([times(737, dA), times(738, dB)]) # there should be only 1 if len(ts) == 1: # and it should be in the morning (h, m) = divmod(peek(ts), 60) if h < 12: printf("A: {dA}; B: {dB} -> {ts} {h:02d}:{m:02d}")Solution: The two services leave simultaneously at 08:33.
The timetable of the trains are as follows:
My alternatives (with frequencies less than 10m) are:
LikeLike
Frits 12:38 pm on 11 July 2021 Permalink |
@Jim, have you considered processing only the first 2 characters of the subsets select parameter? Then you can use select=”Product” instead of select=”M”.
I first thought was a tuple but it turns out to be a generator.
Using
you can still print the content of without emptying it.
—————
I think 04:02 also is a solution, intersection of (dA=45, dB=16) contains 242 and 962 which is valid as 962 >= 720.
LikeLike
Hugh Casement 3:14 pm on 11 July 2021 Permalink |
The use of the definite article in “the two afternoon trains” rather implies that there are no others until evening, though we’re not told when afternoon ends and evening begins. Better, I feel, would have been “the first two trains after noon”, when we would know that the interval is more than 16 minutes, thus excluding a lot of potential solutions.
Possibly that’s what the setter wrote, but it was altered by an editor without consultation — there’s been a history of that over the years.
LikeLike