Chapter 18
Who Steals The Most In A Town Full Of Thieves?
Riddler Express
You’re driving a car down a two-mile track. For the first mile, you drive 30 miles per hour. How fast do you have to go for the second mile in order to average 60 miles per hour for the whole track?
Solution
Average speed over a fixed distance is total distance over total time, so it is the time, not the speed, that must add up. To average mph over two miles you would need a total time of hours, which is minutes. But the first mile alone, driven at mph, already takes hour, which is exactly minutes. The entire time budget is spent before the second mile begins. Solving for the second-mile speed forces , so You would have to cover the second mile in zero time, that is, infinitely fast.
The computation
Solve the average-speed equation symbolically and watch it demand an infinite speed.
import sympy as sp
s = sp.symbols('s', positive=True)
print(sp.solve(sp.Eq(2 / (sp.Rational(1, 30) + 1 / s), 60), s)) # []
print(sp.limit(2 / (sp.Rational(1, 30) + 1 / s), s, sp.oo)) # 60
Riddler Classic
A town of households has a strange law intended to prevent wealth-hoarding. On January of every year, each household robs one other household, selected at random, moving all of that house’s money into their own house. The order in which the robberies take place is also random and is determined by a lottery. (If House A robs House B first, and then C robs A, the houses of A and B would each be empty and C would have acquired the resources of both.) What is the probability that a house is not robbed over the course of the day? And if every house starts with $100, which lottery position has the most expected cash at the end, and how much?
Solution
Who escapes. Fix a house . Each of the other houses independently chooses its victim uniformly among the houses that are not itself, so it picks with probability . House is spared only if none of them choose it: which is essentially . About of the town goes untouched.
Who wins. The best slot is the last. A house acting last can never be robbed afterward, so it keeps everything it holds at the end: its own money plus its victim’s. Its own $100 survives only if none of the earlier robbers took it, worth on average. Its victim is a uniformly random other house, and since the $100,000 in town is conserved, the other houses hold $100,000 minus this house’s own cash, so a random one of them holds on average . Adding the two parts, Acting earlier is strictly worse: it exposes you to being robbed afterward (wiping you out) and your victim has had less time to accumulate. So the last lottery position wins, with about $137.
The computation
Run the town: give every house a random victim and a random lottery order, carry out the robberies in that order, and tally both the fraction of houses left untouched and the average final cash in each lottery position.
import numpy as np
rng = np.random.default_rng(0)
n, runs = 1000, 40000
safe = 0.0; by_pos = np.zeros(n)
for _ in range(runs):
t = rng.integers(0, n - 1, n); t += (t >= np.arange(n)) # victim != self
safe += (n - len(set(t.tolist()))) / n # houses nobody targeted
order = rng.permutation(n)
cash = np.full(n, 100.0)
for h in order:
cash[h] += cash[t[h]]; cash[t[h]] = 0.0
by_pos += cash[order] # cash by lottery position
print(safe / runs) # ~0.368
print(by_pos[-1] / runs, "at the last position") # ~137, the maximum