Chapter 260
Can You Catch The Free T-Shirt?
The Riddler for April 10, 2020. The Express launches T-shirts from a cannon at a random angle and asks which row is the safest bet to catch one. The Classic watches spam comments breed replies and asks how many posts pile up in three days.
Riddler Express
A T-shirt cannon in front of Row can just reach the back of Row (no farther), with no air resistance. The launch angle is uniform between (flat) and (straight up). Which row should you sit in to maximise your chance of catching the shirt?
The Riddler, FiveThirtyEight, April 10, 2020(original post)
Solution
A projectile launched at angle travels a horizontal distance proportional to , and the maximum range (at ) reaches the back of Row . Measuring distance in rows, the shirt lands at As sweeps uniformly from to , the landing row runs from up to and back to . The chance of landing in a given row is governed by how fast changes with : where changes slowly, many angles funnel the shirt into the same row. Since vanishes at , the curve is flattest at its peak, so a wide band of angles all land near the maximum. The most likely landing row is therefore the very back, caught about of the time. (This is the same reason a rainbow is bright at its maximum-deflection angle: probability piles up where the mapping is flat.)
The computation
Encode the launch: draw angles uniformly, send each shirt to row , and tally which row catches the most.
import numpy as np, math
from collections import Counter
th = np.random.default_rng(0).uniform(0, math.pi/2, 20_000_000)
rows = np.clip(np.ceil(100*np.sin(2*th)).astype(int), 1, 100)
cnt = Counter(rows.tolist())
best = max(range(1, 101), key=lambda r: cnt[r])
print(best, round(cnt[best]/len(th), 3)) # 100 0.09
Row catches the most shirts, about of launches, as boxed.
Riddler Classic
Spam comments arrive on the column as a Poisson process: on average one brand-new (top-level) spam comment per day. Every spam post, comment or reply alike, itself attracts replies at an average rate of one per day. Over three days, how many spam posts (comments plus replies) can you expect in total?
The Riddler, FiveThirtyEight, April 10, 2020(original post)
Solution
This is a branching process in continuous time. Consider one post that has days left in which to attract replies, and let be the expected total number of posts in its whole reply tree, counting the post itself. The post spawns replies at rate ; a reply born after days then has days of its own, contributing . So Differentiating gives with , so .
The top-level comments themselves arrive at rate over the three days, and a top-level comment born at time has days remaining, hence an expected tree of posts. Integrating over their arrival times, (Equivalently, the expected count obeys once the column itself is treated as the seed post, giving and genuine spam posts.)
The computation
Encode the actual process: generate top-level arrivals as a rate- Poisson process on , let every post breed replies at rate until day , and average the total count.
import random, math
rng = random.Random(0); T = 3.0; trials = 200_000; total = 0
for _ in range(trials):
stack = []
t = rng.expovariate(1.0)
while t < T: stack.append(t); t += rng.expovariate(1.0) # top-level arrivals
n = 0
while stack:
born = stack.pop(); n += 1
c = born + rng.expovariate(1.0)
while c < T: stack.append(c); c += rng.expovariate(1.0) # replies of this post
total += n
print(total/trials, math.e**3 - 1) # ~19.05, 19.086
The simulated mean (about ) matches , as boxed.