Skip to content
Vamshi Jandhyala

Books · The Riddler

Chapter 231

How Inefficient Can You Make Your Walk To Class?

Riddler Express

The following number pairs refer to coincidences in American history, from 17761776 to the present: (2,6),(?,?),(9,23),(17,36),(26,32).(2, 6), \quad (?, ?), \quad (9, 23), \quad (17, 36), \quad (26, 32). What pair belongs in the second position?

The Riddler, FiveThirtyEight, June 14, 2019(original post)

Solution

Read the numbers as the orders in which presidents served, and the coincidence is a shared surname. The 22nd and 66th presidents were John Adams and John Quincy Adams; the 99th and 2323rd were the Harrisons (William Henry and Benjamin); the 1717th and 3636th were the Johnsons (Andrew and Lyndon); the 2626th and 3232nd were the Roosevelts (Theodore and Franklin). Each pair is two presidents who share a last name.

The list is in alphabetical order of that surname: Adams, then the missing one, then Harrison, Johnson, Roosevelt. The surname falling between Adams and Harrison is Bush, and the two Bushes were the 4141st and 4343rd presidents (George H. W. and George W.). (41,43)\boxed{(41, 43)}

The computation

Encode the actual data and let the pattern fall out: list every president with their order number and surname, find the surnames carried by exactly two different presidents, and sort those pairs alphabetically by surname. The result must be the given sequence with (41,43)(41, 43) in second place. One subtlety: Grover Cleveland was both the 2222nd and 2424th president (non-consecutive terms), but that is one man, not a shared-surname pair, so he is excluded.

from collections import defaultdict
pres = {1:"Washington",2:"Adams",3:"Jefferson",4:"Madison",5:"Monroe",
6:"Adams",7:"Jackson",8:"Van Buren",9:"Harrison",10:"Tyler",11:"Polk",
12:"Taylor",13:"Fillmore",14:"Pierce",15:"Buchanan",16:"Lincoln",
17:"Johnson",18:"Grant",19:"Hayes",20:"Garfield",21:"Arthur",
22:"Cleveland",23:"Harrison",24:"Cleveland",25:"McKinley",26:"Roosevelt",
27:"Taft",28:"Wilson",29:"Harding",30:"Coolidge",31:"Hoover",
32:"Roosevelt",33:"Truman",34:"Eisenhower",35:"Kennedy",36:"Johnson",
37:"Nixon",38:"Ford",39:"Carter",40:"Reagan",41:"Bush",42:"Clinton",
43:"Bush",44:"Obama",45:"Trump"}

by = defaultdict(list)
for n, s in pres.items():
    by[s].append(n)
# surnames held by two DIFFERENT presidents (Cleveland is one man twice -> skip)
pairs = sorted((s, tuple(sorted(v))) for s, v in by.items()
               if len(v) == 2 and s != "Cleveland")
for s, p in pairs:
    print(f"{s:10s} {p}")
print("sequence:", [p for s, p in pairs])
# Adams (2, 6) / Bush (41, 43) / Harrison (9, 23) / Johnson (17, 36) / Roosevelt (26, 32)
# sequence: [(2, 6), (41, 43), (9, 23), (17, 36), (26, 32)]

The second entry is (41,43)(41, 43), the Bushes.

Riddler Classic

You cross a square courtyard, 5050 feet by 5050 feet, entering at the centre of the west wall and leaving at the centre of the south wall. You dislike sharp turns, so every turn has a radius of at least 55 feet, and you never cross your own path. What is the longest walk you could take? Extra credit: can you make your walk a chosen length, say exactly 350350 feet?

The Riddler, FiveThirtyEight, June 14, 2019(original post)

Solution

The surprise is that there is no longest walk. As long as your path is an idealised curve of zero width, you can make it as long as you like.

The constraints are mild. Staying inside the courtyard bounds the region. The turn-radius rule says the path’s radius of curvature is at least 55 feet everywhere, so it cannot wiggle too tightly. The no-crossing rule forbids self-intersection. None of these caps the length, because you can spiral. A spiral coils round and round without ever crossing itself, and you can wind it as many times as you please by making successive coils closer and closer together. The gap between neighbouring coils can shrink toward zero while each coil’s radius of curvature stays comfortably above 55 feet, so an arbitrary number of turns fits inside the courtyard.

For the extra credit, length varies continuously as you add coils, from the short near-direct crossing up to as long as you like, so by the intermediate value theorem every target length above the minimum is attainable, 350350 feet included. You simply wind the spiral until its length is 350350 feet.

The computation

Encode the constraints on an explicit family of spirals and watch the length diverge. Use an Archimedean spiral r(θ)=a+bθr(\theta) = a + b\theta centred in the courtyard, with a,b>0a, b > 0. Its radius of curvature is ρ=(r2+b2)3/2/(r2+2b2)\rho = (r^2 + b^2)^{3/2} / (r^2 + 2b^2), which for small pitch bb is close to rr, so keeping ra=6r \ge a = 6 keeps ρ5\rho \ge 5. Hold the outer radius at 2222 feet (inside the 2525-foot half-width) and shrink the pitch bb: the number of coils and the total length grow without bound while every constraint holds.

  1. For a pitch bb, let rr run from a=6a = 6 to R=22R = 22; the coil count is (Ra)/(2πb)(R - a)/(2\pi b).

  2. Integrate arc length r2+b2dθ\int \sqrt{r^2 + b^2}\,d\theta and track the minimum of ρ\rho.

  3. Shrink bb and watch length diverge with ρ5\rho \ge 5 and r22r \le 22 throughout.

import numpy as np
def spiral_stats(a, R, b):                  # Archimedean spiral r = a + b*theta
    turns = (R - a) / (2 * np.pi * b)
    t = np.linspace(0, 2 * np.pi * turns, int(80 * turns) + 2)
    r = a + b * t
    length = np.trapezoid(np.sqrt(r ** 2 + b ** 2), t)
    rho = (r ** 2 + b ** 2) ** 1.5 / (r ** 2 + 2 * b ** 2)
    return turns, length, rho.min(), r.max()

for b in (1.0, 0.5, 0.2, 0.1, 0.05, 0.02):
    turns, L, rmin, rmax = spiral_stats(6.0, 22.0, b)
    print(f"b={b:5}: turns={turns:6.1f} length={L:9.1f} "
          f"min_rho={rmin:4.2f} r_max={rmax:4.1f}")

from scipy.optimize import brentq                      # extra credit: hit 350 ft exactly
b350 = brentq(lambda b: spiral_stats(6.0, 22.0, b)[1] - 350.0, 0.3, 1.0)
turns, L, rmin, rmax = spiral_stats(6.0, 22.0, b350)
print(f"EC: b={b350:.4f} -> length {L:.1f} ft, min_rho {rmin:.2f}, r_max {rmax:.1f}")
# length grows without bound as b shrinks, with min_rho >= 5 and r_max = 22 (inside court)
# EC: b=0.6408 -> length 350.0 ft, min_rho 5.97, r_max 22.0

As the pitch shrinks, the length climbs through hundreds, thousands, and beyond, while the minimum radius of curvature stays above 55 feet and the spiral never leaves the courtyard or crosses itself. The walk is unbounded, and tuning the pitch lands any chosen length, such as 350350 feet.