Chapter 56
Can You Stick It To The Genie?
You roll three dice in order: a (faces –), a (faces –), then a (faces –), each face equally likely. You win when the three rolls strictly increase, like --. What is your probability of winning? Extra credit: rolling in order, what is the chance the six rolls strictly increase?
Solution
Win when with on the , on the , on the . The rolls are independent and uniform, so the probability is the count of strictly increasing triples divided by . Count them by fixing the first two and letting the last run free: for each and each with , the top die can be any of the values above . Summing, The clean answer is a small coincidence of these particular face counts, not a general law. With six dice the same idea (count increasing sextuples, divide by ) has no tidy closed form; the exact value is
The computation
Enumerate every outcome of the dice in order and count the fraction that strictly increase.
from fractions import Fraction as F
from itertools import product
def prob(faces):
rolls = product(*[range(1, f + 1) for f in faces])
wins = sum(all(x < y for x, y in zip(r, r[1:])) for r in rolls)
total = 1
for f in faces: total *= f
return F(wins, total)
print(prob([4, 6, 8])) # 1/4
print(prob([4, 6, 8, 10, 12, 20]), float(prob([4, 6, 8, 10, 12, 20])))
# 2717/230400, 0.0118