Sunday Times Teaser 2889 – Catching the Bus
by Michael Fletcher
Published February 4 2018 (link)
I can travel to town by either the number 12 bus or the number 15 bus. The number 12 bus leaves every 12 minutes and the number 15 bus leaves every 15 minutes. The first number 15 bus leaves soon after the first number 12 bus. I arrive at the bus stop at random and catch the first bus to arrive.
If the probability of me catching the number 15 bus is 2/5 how soon does the first number 15 bus leave after the first number 12 bus?
One Comment
Leave one →
-
Brian Gladman permalink123456789101112131415161718192021222324252627282930313233f1, f2 = False, False# events for bus number 12 over the first hour (in seconds)ev15 = [(60 * x, 12) for x in range(0, 61, 12)]# the initial time delay in seconds between buses 12 and 15for delay in range(0, 3600):# events for bus number 15 over the first hour (in seconds)ev12 = [(60 * x + delay, 15)for x in range(0, 61, 15) if 60 * x + delay <= 3600]# accumulate the waiting times for bus numbers 12 and 15waits = [0, 0]# consider the events in the first hour in time orderfor time, bus in sorted(ev12 + ev15):if time:# accumulate the waiting times for each bus numberwaits[0 if bus == 12 else 1] += time - last_buslast_bus = time# the probabilities for bus numbers 12 and 15 3/5 and 2/5if 2 * waits[0] == 3 * waits[1]:# output the delay in minutes and secondsm, s = divmod(delay, 60)ms = f'{m} minute' + ('s' if m > 1 else '')ss = '.' if not s else f' {s} seconds.'if not s and not f2:print('Other solutions (first hour only):')f2 = Trueprint(f' Delay = {ms + ss}')if not f1:print('Other solutions:')f1 = True