Skip to content
Vamshi Jandhyala

Books · The Riddler

Chapter 47

Can You Reach The Summit First?

Riddler Express

Each week, between one and five people show up from each of three towns (Blacksburg, Greensboro, Silver Spring), every count equally likely. They want two equal teams with two towns against the third. What is the probability this is possible? Extra credit: between one and NN per town?

Solution

Two equal teams with two towns against the third means one town’s headcount equals the sum of the other two: b+g=sb+g = s, or b+s=gb+s = g, or g+s=bg+s = b. With each count uniform on 1,,N1,\dots,N there are N3N^3 equally likely triples. The equation b+g=sb + g = s has s1s-1 solutions for each ss, so s=2N(s1)=N(N1)2\sum_{s=2}^{N}(s-1) = \tfrac{N(N-1)}{2} of them; the three equations are mutually exclusive (any two would force a town to have zero people), so Pr(two equal teams)=3N(N1)2N3=3(N1)2N2.\Pr(\text{two equal teams}) = \frac{3\cdot\tfrac{N(N-1)}{2}}{N^3} = \frac{3(N-1)}{2N^2}. For N=5N = 5 this is 34225=625=0.24\dfrac{3\cdot 4}{2\cdot 25} = \dfrac{6}{25} = \boxed{0.24}.

The computation

Count the triples that satisfy one of the three balance equations.

from itertools import product
from fractions import Fraction as F
N = 5
good = sum(b+g == s or b+s == g or g+s == b
           for b, g, s in product(range(1, N+1), repeat=3))
print(F(good, N**3))                         # 6/25

Riddler Classic

You race three others up a mountain; the summit awards 5,3,2,15,3,2,1 points for first through fourth. All four are equally fast, but two of your rivals are teammates: the slower teammate is pulled up to the faster one’s time, so they finish together. How many points can you expect?

Solution

Call yourself AA, the lone rival BB, and the teammates C,CC,C. The teammates cross at the faster one’s time, so in the finishing order the two CCs collapse onto the earlier of their two positions. The catch: if you finish between the two teammates, the trailing teammate is dragged up past you, so both teammates end ahead of you.

The four riders fall into (42)2=12\binom{4}{2}\cdot 2 = 12 equally likely order patterns of {A,B,C,C}\{A,B,C,C\}. Scoring each by your resulting place (with the collapse applied) and averaging gives E[points]=29122.42.\mathbb{E}[\text{points}] = \frac{29}{12} \approx \boxed{2.42}. A lone rider with no teammates in the field would average 5+3+2+14=114=2.75\tfrac{5+3+2+1}{4} = \tfrac{11}{4} = 2.75, so the rival partnership quietly costs you about a third of a point.

The computation

Enumerate the twelve finish-order patterns; for each, work out your place after the trailing teammate is pulled up to the leading one, and average the points.

from itertools import permutations
from fractions import Fraction as F
total = F(0); n = 0
for p in set(permutations('ABCC')):
    a = p.index('A'); c1, c2 = [i for i, x in enumerate(p) if x == 'C']
    n += 1
    if a == 0:               total += 5       # you are first
    elif a == 3:             total += 1        # you are last
    elif c1 < a < c2:        total += 2 if a == 1 else 1   # between teammates
    else:                    total += 3 if a == 1 else 2
print(total / n)                              # 29/12