Skip to content
Vamshi Jandhyala

Books · The Riddler

Chapter 245

Can You Escape The Enemy Submarines?

Riddler Express

An auditorium has 200200 seats numbered 11 to 200200. 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 kk, then it cannot be divisible by any multiple of kk either. So if kk has another multiple in 11 to 200200 (namely 2k2002k \le 200), that multiple would also fail, and we would have more than two non-dividing seats. To have only kk fail, kk must have no multiple 200\le 200 besides itself, i.e. 2k>2002k > 200, so k>100k > 100. Both excluded seats lie above 100100.

Moreover each excluded seat must be the highest power of some prime below 200200: if k=pamk = p^a m with m>1m > 1, then the smaller factors pap^a and mm (both 100<k\le 100 < k, hence included) already force divisibility by kk, so kk could not fail. So we need two consecutive numbers above 100100, each a prime power. One of any two consecutive numbers is even, so it is a power of 22; the largest power of 22 below 200200 is 27=1282^7 = 128. Its neighbour 129=3×43129 = 3 \times 43 is not a prime power, but 127127 is prime. So the two seats are 127 and 128.\boxed{127 \text{ and } 128}.

The computation

Encode the condition directly: for each consecutive pair (k,k+1)(k, k+1), take the least common multiple of all the other seat numbers and check that it is divisible by neither kk nor k+1k+1. 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 (127,128)(127, 128) 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 2.332.33 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: NN 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 3.3963.396 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 NN 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 (3.396\approx 3.396 for two subs) is recorded here.