Pick 1 of 3 Desserts Using Only a Coin

Alice wants Cake, Ice Cream, and Pudding to each be chosen with probability exactly 1/3.

Algorithm
Switch between a fair coin and an unknown biased coin.

Toss the fair coin twice

HH
🍰 Cake
Probability 1/4
HT
🍦 Ice Cream
Probability 1/4
TH
🍮 Pudding
Probability 1/4
TT
↻ Retry
Probability 1/4
We keep only HH, HT, TH. Since those three outcomes are equally likely, conditioning on acceptance gives
(1/4) / (3/4) = 1/3
for each dessert.
Interactive simulation
Simulating the fair-coin algorithm.
LATEST RESULT
Press “Pick once”.
🍰 Cake 0.00%
🍦 Ice Cream 0.00%
🍮 Pudding 0.00%
0 accepted picks Target: 33.33% each
How to discover the solution in an interview
1. Notice the mismatch
One fair coin gives 2 states, but you need 3 equally likely choices.
2. Create a power of two
Two fair tosses give 4 equally likely states. Assign 3 and reject 1.
3. Remove unknown bias
For a biased coin, HT and TH have equal probability, so use them as fair bits.