Chapter 245
Can You Escape The Enemy Submarines?
Riddler Express
An auditorium has seats numbered to . A speaker has a whole number that is evenly divisible by every seat number except two, and those two seats are next to each other (consecutive numbers). Which two seat numbers are they?
The Riddler, FiveThirtyEight, October 11, 2019(original post)
Solution
If the number is not divisible by some seat , then it cannot be divisible by any multiple of either. So if has another multiple in to (namely ), that multiple would also fail, and we would have more than two non-dividing seats. To have only fail, must have no multiple besides itself, i.e. , so . Both excluded seats lie above .
Moreover each excluded seat must be the highest power of some prime below : if with , then the smaller factors and (both , hence included) already force divisibility by , so could not fail. So we need two consecutive numbers above , each a prime power. One of any two consecutive numbers is even, so it is a power of ; the largest power of below is . Its neighbour is not a prime power, but is prime. So the two seats are
The computation
Encode the condition directly: for each consecutive pair , take the least common multiple of all the other seat numbers and check that it is divisible by neither nor . Exactly one pair should qualify.
from math import gcd
from functools import reduce
def lcm(a, b): return a * b // gcd(a, b)
hits = []
for k in range(1, 200):
L = reduce(lcm, (m for m in range(1, 201) if m != k and m != k + 1))
if L % k != 0 and L % (k + 1) != 0:
hits.append((k, k + 1))
print("excluded consecutive pair(s):", hits)
# excluded consecutive pair(s): [(127, 128)]
Only works, as the prime-power argument predicts.
Riddler Classic
An enemy submarine sits exactly halfway between your ship and your home port; with one sub, your ship must be about times faster than the sub to guarantee escape. Now the enemy deploys two submarines so that your ship, the two subs, and the harbour are evenly spaced along a straight line. How much faster than the subs must your ship be to guarantee reaching the harbour? Extra credit: evenly spaced submarines.
The Riddler, FiveThirtyEight, October 11, 2019(original post)
Status
This is a continuous pursuit-and-evasion problem. Because the ship has no information about a submarine’s movements, the danger zone around each sub is a disk that expands at the sub’s speed, and the ship must reach the harbour while never letting any disk catch it. The winning path is a straight run followed by a curve hugging the expanding circle, and the critical speed ratio is the root of a transcendental condition solved with calculus and numerics, not a closed form. For two subs the answer is that the ship must be about times faster than the subs; only the submarine nearest the harbour binds the answer (it has the least time before the harbour falls inside its disk), and by a similar-triangles argument the path that just evades it also clears the other. For evenly spaced subs the same “only the harbour-side sub matters” principle holds, with the ratio growing as that sub starts closer to the harbour.
Because the result rests on a calculus-and-numerics evasion analysis illustrated by an essential animation rather than a self-contained derivation to the worked-solution bar, the Classic is deferred, in the same category as the column’s other continuous geometric pursuit puzzles. The headline ( for two subs) is recorded here.