Chapter 278
Can You Cover The Globe?
The Riddler for August 28, 2020. The Express revisits the classic rope-around-the-Earth trick, but for a sheet covering the whole sphere. The Classic asks how many games of War you would expect to play before seeing one that lasts exactly 26 turns with no “wars”.
Riddler Express
A rope around the equator, raised metre off the ground everywhere, needs only extra metres. Now cover the whole globe with a sheet lying flat on the ground, and raise the entire sheet metre. By how much must the sheet’s area increase? Take the Earth as a perfect sphere of radius km. (Extra credit: name a place whose area is close to the answer.)
The Riddler, FiveThirtyEight, August 28, 2020(original post)
Solution
A sphere of radius has surface area . Lifting the sheet metre everywhere wraps it on a sphere of radius , area . The increase is The leading term scales with the Earth’s radius, so unlike the rope (whose is independent of ), the sheet’s extra area is large. With m, A square kilometre is a million square metres (not a thousand), so the answer is about km, a shade over of the Earth’s surface. The country closest in size is Liechtenstein, at km.
The computation
Encode the two surface areas and subtract; the radius cancels into .
import math
R = 6_378_000 # metres
dA = 4 * math.pi * ((R + 1)**2 - R**2) # 4*pi*(2R+1)
print(round(dA / 1e6, 1)) # 160.3 (square kilometres)
print(round((8 * math.pi * R + 4 * math.pi) / 1e6, 1)) # 160.3 (same)
print(round(100 * dA / (4 * math.pi * R**2), 5)) # 0.00003 percent
The sheet’s area must grow by about km, the size of Liechtenstein.
Riddler Classic
In War, a shuffled deck is split into two piles of . Each turn both players flip their top card; the higher rank wins. If the ranks match, a mini “war” breaks out. A “perfect” game lasts exactly turns with no wars: one player wins every turn outright. Assuming a fresh shuffle before each game, how many games would you expect to play before seeing a perfect one?
The Riddler, FiveThirtyEight, August 28, 2020(original post)
Solution
Let be the probability that a single random game is perfect. Then the number of games until the first perfect one is geometric: it equals with probability , and its expectation is the arithmetico-geometric sum So everything reduces to finding .
Counting perfect games. Shuffle the cards; your pile is the first , the opponent’s the last , and turn pairs card with card . A perfect game for you needs your rank strictly above theirs on all turns (no ties). Equivalently, pair the cards into unordered pairs, with no pair sharing a rank (a tie would force a war), and on each turn give the higher card to you. Every such no-tie pairing yields exactly one perfect deal once the pairs are dealt to turns ( orders), so the number of perfect deals is , where counts no-tie pairings. Hence so , where is the chance a random pairing has no equal-rank pair. The crude estimate (win coin flips) is an overestimate; the factor corrects for ties.
Counting no-tie pairings. By inclusion–exclusion on the “bad” equal-rank pairs: within one rank (four suits) the number of ways to pick disjoint pairs is for , so across ranks the count of disjoint bad pairs is the coefficient of . Each choice of bad pairs leaves cards to pair freely, in ways: This gives, exactly matching Angela Zhou’s value, The expected number of games until you sweep is million; until either player sweeps it is half that.
The computation
Encode the count of no-tie deck pairings by inclusion–exclusion, then form and its reciprocal. The exact rational matches the official solution.
from math import factorial
from fractions import Fraction
def matchings(m): # perfect matchings of m cards = (m-1)!!
r, m = 1, m - 1
while m > 1:
r *= m; m -= 2
return r
poly = [1] # (1 + 6x + 3x^2)^13 ; c_k = coeff of x^k
for _ in range(13):
new = [0] * (len(poly) + 2)
for i, a in enumerate(poly):
new[i] += a; new[i+1] += 6*a; new[i+2] += 3*a
poly = new
N = sum((-1)**k * c * matchings(52 - 2*k) for k, c in enumerate(poly))
p = Fraction(N) * factorial(26) / factorial(52)
print(float(p)) # 3.1324361743e-09
print(float(1/p), float(1/(2*p))) # 319240343.4 ; 159620171.7
official = Fraction(29908397871631390876014250000, 93686147409122073121)
print((1/p) == official) # True
The analytic reproduces the official exact fraction, giving about million games to win a perfect sweep yourself, or million until either player does.