Skip to content
Vamshi Jandhyala

Books · The Riddler

Chapter 272

Can The Hare Beat The Tortoise?

Riddler Express

Your true batting average is .350.350 (a 35%35\% chance of a hit each at-bat), with four at-bats per game. What is your chance of batting at least .400.400 over a 6060-game season, and how does that compare with a 162162-game season? Extra credit: your chance of a hitting streak of at least 5656 games (tying DiMaggio) in each season.

The Riddler, FiveThirtyEight, July 17, 2020(original post)

Solution

Each at-bat is an independent hit with probability 0.350.35. Over 6060 games that is 240240 at-bats, and batting .400.400 means at least 0.4×240=960.4\times 240 = 96 hits; the number of hits is Binomial(240,0.35)(240, 0.35), so the chance is the upper tail Pr(hits96)\Pr(\text{hits} \ge 96). Over 162162 games it is 648648 at-bats needing 260\ge 260 hits. The tails are 6.1% over 60 games,0.38% over 162 games,\boxed{6.1\% \ \text{over } 60 \text{ games}, \qquad 0.38\% \ \text{over } 162 \text{ games}}, so a short season makes .400.400 about 1616 times more reachable: fewer at-bats mean more sampling variation around the true mean.

The streak runs the other way. A single game yields a hit with probability 1(10.35)4=82.15%1 - (1-0.35)^4 = 82.15\%, but stringing 5656 such games together is punishing. The chance of a streak of at least 5656 games is 0.0028% over 60 games,0.033% over 162 games,0.0028\% \ \text{over } 60 \text{ games}, \qquad 0.033\% \ \text{over } 162 \text{ games}, roughly ten times likelier in the long season, which simply has more starting points for a long run. (Batting .400.400 and streaking 5656 games is rarer still, and positively correlated, since both demand a glut of hits.)

The computation

Encode the binomial tail for the .400.400 question and a short dynamic program over games (carry the current streak length, absorbing at 5656) for the streak.

from math import comb
from functools import lru_cache
def tail(at_bats, need, p=0.35):
    return sum(comb(at_bats, k) * p**k * (1 - p)**(at_bats - k)
               for k in range(need, at_bats + 1))
print(round(tail(240, 96) * 100, 2), round(tail(648, 260) * 100, 3))   # 6.08 0.379
pg = 1 - (1 - 0.35) ** 4                              # hit in a game
def streak(G, L=56):
    @lru_cache(None)
    def f(g, run):
        if run >= L: return 1.0
        if g == 0: return 0.0
        return pg * f(g - 1, run + 1) + (1 - pg) * f(g - 1, 0)
    return f(G, 0)
print(round(streak(60) * 100, 4), round(streak(162) * 100, 4))         # 0.0028 0.0329

Riddler Classic

A 1010-mile race runs along a road that instantly stretches by 1010 miles at the end of every minute (uniformly, carrying the cars with it). The tortoise drives 6060 mph, the hare 7575 mph. The tortoise starts at the gun; how long should the hare wait so that the two finish at the same instant?

The Riddler, FiveThirtyEight, July 17, 2020(original post)

Solution

Because the road stretches uniformly, the right variable is the fraction of the road a car has covered, not its distance: stretching carries a car forward in proportion, leaving its fraction unchanged. At 6060 mph the tortoise covers 11 mile in the first minute, 110\tfrac1{10} of the then 1010-mile road. In the second minute it adds 11 mile of a 2020-mile road, 120\tfrac1{20}; in the nnth minute, 110n\tfrac1{10n}. So after nn minutes its fraction covered is 110(1+12++1n)=Hn10,\frac1{10}\Bigl(1 + \tfrac12 + \cdots + \tfrac1n\Bigr) = \frac{H_n}{10}, which first reaches 11 at n=12,367n = 12{,}367 minutes (about 8.68.6 days): the harmonic series diverges, so the tortoise does finish, eventually.

The hare drives 7575 mph, exactly 25%25\% faster, so over any shared stretch of time it covers 25%25\% more of the road. To tie, it should have 25%25\% more road left to cover when it starts, that is, it should leave when the tortoise has completed 11.25=80%\tfrac{1}{1.25} = 80\%... equivalently the hare may wait until the tortoise has completed 20%20\% and then cover the rest in lockstep to the line. The tortoise’s fraction reaches 0.20.2 partway through the fourth minute, at 3 minutes and 40 seconds.\boxed{3 \text{ minutes and } 40 \text{ seconds}}.

The computation

Encode the tortoise’s fraction-per-minute 110n\tfrac1{10n}: sum it until the road is complete (the harmonic finish), and find the instant the fraction crosses 0.20.2 (the hare’s cue).

H, n = 0.0, 0
while H < 10:
    n += 1; H += 1 / n                       # fraction covered = H/10
print("tortoise finishes at minute", n)      # 12367
frac, t = 0.0, 0
while frac < 0.2:
    t += 1; frac += 1 / (10 * t)
prev = frac - 1 / (10 * t)                    # fraction at start of minute t
into = (0.2 - prev) / (1 / (10 * t))          # fraction into minute t
start = (t - 1) + into
print(f"hare waits {int(start)} min {round((start % 1) * 60)} s")   # 3 min 40 s