Gambler's ruin is the sharpest tool-to-questions ratio in quant prep: you start with $a$ chips, win or lose one per round, and stop at $N$ (target) or 0 (ruin). An enormous number of interview questions — racing games, token puzzles, "first to X wins", drunk-on-a-cliff — are this problem in costume.
The two formulas
Fair game ($p = 1/2$): probability of reaching $N$ before 0 from $a$ is simply
$$P(\text{win}) = \frac{a}{N}$$
and the expected duration is $a(N-a)$ rounds — both provable in two lines with martingales ($S_n$ and $S_n^2 - n$).
Biased game ($p \neq 1/2$, $r = q/p$):
$$P(\text{win}) = \frac{1 - r^{a}}{1 - r^{N}}$$
The structure to remember: ratios of geometric terms in $r = q/p$. Even a small per-round edge compounds brutally — that is the lesson interviewers want you to articulate.
Worked example
You have 3 chips, I have 7, fair coin, one chip per flip until someone is broke. Your chance of taking everything: $3/10$. Expected number of flips: $3 \times 7 = 21$. Now bias it: if you win each flip with $p = 0.51$, $r = 49/51 \approx 0.961$, and your win probability jumps from 30% to about $\frac{1 - 0.961^3}{1 - 0.961^{10}} \approx 36\%$ — a 2% edge per flip moved the outcome 6 points. Casinos, market makers, and HFT firms are all in the business of that arithmetic.
How interviews disguise it
- Racing/pattern games — "first player to be up 3" is ruin with $N - a = a = 3$.
- Boundary questions — a drunk walking between a cliff and a bar is ruin with one absorbing barrier moved to infinity (for $p \le 1/2$, ruin is certain; expected time infinite at $p = 1/2$ — a classic follow-up).
- Bankroll questions — "how big must your bankroll be to survive a losing streak" bridges directly into Kelly sizing.
Practice with solutions
- Gambler's ruin on a fair coin — the canonical setup, fully worked.
- Gambler's ruin with biased dice — the $r = q/p$ machinery in action.
- Biased random walk reaching +1 — the one-barrier variant.
- Absorption probability on a finite walk — the general absorbing-chain view.
More topic guides
- Bayes' Theorem in Quant Interviews
- Coin Flip Questions in Quant Interviews
- Dice Questions in Quant Interviews
- The Kelly Criterion in Quant Interviews
- Markov Chains in Quant Interviews
- Martingales in Quant Interviews
- The Monty Hall Problem — and the Variants Interviews Actually Ask
- Optimal Stopping in Quant Interviews
- Random Walks in Quant Interviews
- All guides & explainers
Frequently asked questions
What is the gambler's ruin formula?
Fair game: starting with a chips aiming for N, P(win) = a/N and expected duration a(N−a). Biased game with per-round win probability p: P(win) = (1 − r^a)/(1 − r^N) where r = q/p.
Why is gambler's ruin so common in trading interviews?
Because most 'first to X' games, token puzzles, and boundary questions are gambler's ruin re-skinned, and because its central lesson — small per-round edges compound into large outcome differences — is the economics of market making.
What happens with only one boundary (no target)?
Against an infinitely rich opponent: if p ≤ 1/2 ruin is certain, and at exactly p = 1/2 ruin is certain but the expected time is infinite. If p > 1/2 you escape ruin with probability 1 − (q/p)^a.
How do I solve gambler's ruin without memorizing formulas?
First-step analysis (condition on one round, solve the recursion) or martingales: S_n gives the win probability and S_n² − n gives the expected duration for the fair case, each in a couple of lines.
Practice the real thing
QuantVault has 2,800+ quant interview problems with full solutions, intuition, and hints, firm-by-firm interview funnels, and an auto-graded coding judge. Start free.