How Long the Gambler's Ruin Game Lasts
Beyond just the win probability in gambler's ruin, how many bets should you expect to place before the game ends — a related but distinct question with its own clean formula.
Prerequisites: Gambler's Ruin
The problem. You have $ and repeatedly bet $1 on fair coin flips against an opponent who has $, until one of you is ruined (reaches $0). The classic gambler's ruin question asks: what's the probability you end up with all $? A less commonly asked but equally clean follow-up is: how many bets, on average, does the game last before someone is ruined? That's a genuinely different quantity, and it has its own formula worth knowing.
Setting up the recursion
Let be the expected number of remaining bets when you currently have $ (opponent has ), with the game ending at or . Each bet is one flip, after which you're at or with equal probability, so:
The "+1" accounts for the bet you just placed to get there. This is a linear recursion, and the classic solved form for a fair game is:
In plain English: the expected number of bets is your current stake times your opponent's stake — a simple product, peaking when the two players are evenly matched and shrinking toward zero as either side approaches having all the money (little left to fight over).
Worked example: even match vs lopsided match
Say the total pot is and you start with (an even match). Expected duration: bets. Now suppose you start with only against an opponent with $18. Expected duration: bets — much shorter, because with only $2 to lose, you're very likely to be ruined quickly, and there simply isn't much room for a long back-and-forth. Notice the game lasting the longest happens exactly when it's most evenly matched, which matches intuition: an even fight has the most "room" to swing back and forth before anyone runs out.
Worked example: checking against , by hand
With , formula gives expected bets. Verify with the recursion directly: by symmetry . Writing out and (using ), substitute: . Matches the formula exactly.
is a downward-opening parabola in , which is exactly the shape on the explorer above — peaking at the midpoint and falling to zero at both ends. Drag the curve and notice the peak always sits exactly halfway between the roots, matching where .
The general technique
This is the same "set up a recursion, use boundary conditions, solve" method that answers the win-probability version of gambler's ruin, just tracking a different quantity (expected steps rather than absorption probability). The lesson that generalizes: for any absorbing random walk, both "probability of which boundary you hit" and "expected time until you hit a boundary" satisfy their own linear recursions with the same boundary conditions, and both tend to have clean closed forms for a fair (unbiased) walk.
In fair-coin gambler's ruin with stakes $ and $, the expected number of bets until ruin is — maximized when the two sides are evenly matched and shrinking to zero as one side nears having everything.
Sanity-check any gambler's-ruin duration answer against the symmetric case : that's where the game should last longest, since is maximized at .
Practice in interviews
Further reading
- Feller, An Introduction to Probability Theory, vol. 1, ch. 14