Chapter 180
How To Cross The Street
Riddler Express
Suppose you have circles, all of which are joined so that their centers lie on a larger circle (with the small circles tangent to their neighbours along that ring). What is the ratio of the diameter of the larger circle to the diameter of the smaller circles?
The Riddler, FiveThirtyEight, April 20, 2018(original post)
Solution
The picture. Place the small circles around the larger circle of radius , so that each small circle has its centre on the big circle and the chain of small circles closes up with neighbours tangent to one another. By symmetry, the centres form a regular -gon inscribed in the big circle. Let be the common radius of the small circles.
One angle does all the work. Pick two adjacent small circles and join their centres to the centre of the big circle. The two centres lie on the big circle at radius , separated by the central angle . The chord between them is the segment connecting their centres, and because the two small circles are tangent that chord has length .
The chord of a circle of radius subtending a central angle has length . With that gives Diameters scale the same way, so the diameter ratio equals the radius ratio. The answer is At this gives ratio (the classic six-around-one packing); at it gives .
The computation
Place the centres explicitly on a unit-radius big circle and check that adjacent small circles are tangent.
Put centre at for .
Measure the Euclidean distance between centre and centre ; that distance equals .
Compare with for a sweep of .
import math
for N in [3, 4, 6, 8, 12, 20, 100]:
cx0, cy0 = 1.0, 0.0
cx1, cy1 = math.cos(2*math.pi/N), math.sin(2*math.pi/N)
d_centres = math.hypot(cx1 - cx0, cy1 - cy0)
r = d_centres / 2
R_over_r = 1.0 / r
formula = 1.0 / math.sin(math.pi/N)
print(f"N={N:3d}: R/r measured = {R_over_r:.6f}, formula = {formula:.6f}")
The two columns match to machine precision for every , confirming the boxed ratio.
Riddler Classic
You and a partner are meeting a friend at a restaurant in a city whose streets are laid out as a grid. Every intersection has pedestrian signals that let people walk in only one direction at a time, and the signals alternate. Each “walk” signal and each “don’t walk” signal lasts for the same fixed duration . You are located at point and the restaurant is at point , one block north and two blocks east of . The intersection at shows a “walk” signal allowing you to go north and a “don’t walk” timer for east currently reading second. The other intersections’ signals are at unknown points in their cycles. You can cross only one street at each intersection, you cannot jaywalk, and you want to reach as fast as possible. Which direction should you go first?
The Riddler, FiveThirtyEight, April 20, 2018(original post)
Solution
The setup. Label the grid by (east blocks remaining, north blocks remaining). You start at and want to reach . At a grid point with both coordinates positive you can choose either direction; at with you must go east; at with you must go north. At the starting intersection you may go north right now (wait ) or wait second and go east.
The wait at an unknown intersection, going in a forced direction. At every other intersection the cycle phase is uniform on . Each direction shows the walk signal for exactly half the cycle. If you arrive needing to go in a specific direction, the chance you can walk immediately is . Conditional on a don’t-walk signal, the time until your direction switches to walk is uniform on , with mean . So your expected wait at a forced-direction intersection is This uses no information about other intersections beyond the cycle length.
The wait at an intersection with a choice. If both directions are still open ( with ), one of the two signals is showing walk right now. Cross in whichever direction the signal allows. The wait is .
Compare the two opening moves. Going north from costs seconds and lands at , which is forced east twice. The expected total wait from to along this route is Going east from costs second and lands at , which has a choice (so the next wait is ). After that move you reach either or , in both cases a forced single move with expected wait . Total:
Which is smaller? East beats north exactly when Walk-and-don’t-walk durations of seconds or less are very short for an actual urban grid. In the regime of any real city,
Why the choice is worth a second. The general principle is that crossings with multiple legal directions cost nothing in expected wait, while forced crossings cost . Going east immediately spends second to convert a forced east leg into a choice intersection: a saving of in expected wait downstream. Whenever the cycle is long enough that , options are worth more than the second they cost. The rule extends: at any intersection, prefer the move that buys a choice over a move that leaves you forced.
The computation
Simulate the journey. Use the cycle convention in which one full cycle has length , with phase uniform on at each non-starting intersection; the north walk shows for and the east walk for .
At , apply the deterministic move: north costs , east costs .
At each subsequent intersection, draw a fresh phase. If forced, compute the wait until the right walk starts; if free, take whichever direction is walking.
Average over many trials for both opening strategies and a sweep of cycle lengths.
import random
def trip(T, start, trials=200000):
total = 0.0
for _ in range(trials):
e, n = 2, 1
t = 0.0
if start == 'N':
n -= 1
else:
t += 1.0; e -= 1
while e > 0 or n > 0:
phi = random.uniform(0, 2 * T)
n_walks = phi < T
if e == 0:
t += 0.0 if n_walks else (2 * T - phi); n -= 1
elif n == 0:
t += (T - phi) if n_walks else 0.0; e -= 1
else:
if n_walks: n -= 1
else: e -= 1
total += t
return total / trials
for T in [3, 4, 5, 6, 8, 12]:
n_avg = trip(T, 'N')
e_avg = trip(T, 'E')
print(f"T={T:2d}: north first -> {n_avg:.3f}s, "
f"east first -> {e_avg:.3f}s")
At north first wins (s vs s); at the two tie at s; for east first wins by an amount that grows with . The crossover is exactly at , matching the boxed inequality.