Race Between Two Patterns on a Fair Die
You roll a fair six-sided die repeatedly. The process stops the first time you see either the pattern $6, 6$ (two consecutive sixes) or the pattern
What is the probability that the process stops because
Build a minimal finite-state Markov chain where each state tracks the longest suffix of the roll history that is a prefix of either target pattern, and solve exactly for the absorption probability.
Hints
- Track progress toward both patterns simultaneously. The state you need is the longest suffix of the roll history that matches a prefix of either $6, 6$ or , 2, 3$.
- There are exactly 4 transient states: no progress ($\emptyset$), last roll was
$, last two rolls were, 2$, and last roll was $6$. Write the transition probabilities carefully -- note that rolling a$ from any state always resets to the $\langle 1 \rangle$ state.- Let $p_i$ be the probability that
, 2, 3$ wins from state $i$. You get a $4 \times 4$ linear system. Start by using the $S_0$ and $S_6$ equations to express $p_1$ and $p_6$ in terms of $p_0$, then substitute into the remaining equations.Worked Solution
How to Think About It: This is a pattern-race problem -- two target strings are competing to appear first in a stream of i.i.d. die rolls. The standard approach is to build an Aho-Corasick-style automaton: each state represents the longest suffix of the roll history that is a prefix of either target pattern. Transitions are deterministic given the current state and the new roll. Then you solve a system of linear equations for the absorption probabilities.
Before doing any algebra, think about which pattern has the advantage. Pattern $6, 6$ needs only 2 specific rolls with probability
/6$ each, while, 2, 3$ needs 3 specific rolls. But the key subtlety is overlap: after a failed attempt at $6, 6$ (say you rolled 6 then something else), you lose all progress. After a failed, 2, 3$ attempt (say, 2, 5$), you also lose progress. The shorter pattern has a big structural edge here.Quick Estimate: Pattern $6, 6$ has expected first-arrival time around $6 \times 6 + 6 = 42$ rolls (geometric waiting for each 6 in sequence). Pattern
, 2, 3$ has expected first-arrival around $6^3 + 6^2 + 6 = 258$ rolls (roughly -- each step has a/6$ chance of advancing). So $6, 6$ should win most of the time, and $P(1,2,3 \text{ first})$ should be well below $0.5$ -- probably in the range $0.1$-$0.2$.Approach: Define states by the longest suffix of the history that is a prefix of either target, solve a $4 \times 4$ linear system.
Formal Solution:
The two target patterns are $6, 6$ and
, 2, 3$. The relevant prefixes are:- $\emptyset$: no useful suffix
- $\langle 1 \rangle$: last roll was $ (prefix of,2,3$)
- $\langle 1,2 \rangle$: last two rolls were
, 2$ (prefix of,2,3$)- $\langle 6 \rangle$: last roll was $6$ (prefix of $6,6$)
Note that no roll can simultaneously advance progress toward both patterns (since
\neq 6$), so there is no state tracking joint progress.The absorbing states are $\langle 1,2,3 \rangle$ (pattern
,2,3$ wins) and $\langle 6,6 \rangle$ (pattern $6,6$ wins).52$:Transition table (each row sums to
$; all transitions have probabilityp_0 = p_1 + p_6$:/6$ per die face):p_0 = p_1 + p_6$.| From | Roll 1 | Roll 2 | Roll 3 | Roll 4 | Roll 5 | Roll 6 | |------|--------|--------|--------|--------|--------|--------| | $S_0$ | $S_1$ | $S_0$ | $S_0$ | $S_0$ | $S_0$ | $S_6$ | | $S_1$ | $S_1$ | $S_{12}$ | $S_0$ | $S_0$ | $S_0$ | $S_6$ | | $S_{12}$ | $S_1$ | $S_0$ | ABS | $S_0$ | $S_0$ | $S_6$ | | $S_6$ | $S_1$ | $S_0$ | $S_0$ | $S_0$ | $S_0$ | ABS |
Let $p_i = P(\text{pattern } 1,2,3 \text{ wins} \mid \text{start in state } i)$. The system of equations:
$p_0 = \frac{1}{6}p_1 + \frac{1}{6}p_6 + \frac{4}{6}p_0$
$p_1 = \frac{1}{6}p_1 + \frac{1}{6}p_{12} + \frac{1}{6}p_6 + \frac{3}{6}p_0$
$p_{12} = \frac{1}{6}(1) + \frac{1}{6}p_1 + \frac{1}{6}p_6 + \frac{3}{6}p_0$
$p_6 = \frac{1}{6}(0) + \frac{1}{6}p_1 + \frac{4}{6}p_0$
From the first equation:
From the fourth: $p_6 = \frac{1}{6}p_1 + \frac{2}{3}p_0$.
Substituting into
$2p_0 = p_1 + \frac{1}{6}p_1 + \frac{2}{3}p_0 = \frac{7}{6}p_1 + \frac{2}{3}p_0$
$\frac{4}{3}p_0 = \frac{7}{6}p_1 \implies p_1 = \frac{8}{7}p_0$
Then $p_6 = \frac{1}{6} \cdot \frac{8}{7}p_0 + \frac{2}{3}p_0 = \frac{4}{21}p_0 + \frac{14}{21}p_0 = \frac{6}{7}p_0$.
From the third equation: $p_{12} = \frac{1}{6} + \frac{1}{6} \cdot \frac{8}{7}p_0 + \frac{1}{6} \cdot \frac{6}{7}p_0 + \frac{1}{2}p_0 = \frac{1}{6} + \frac{5}{6}p_0$.
Substitute everything into the second equation:
$\frac{8}{7}p_0 = \frac{1}{6} \cdot \frac{8}{7}p_0 + \frac{1}{6}\left(\frac{1}{6} + \frac{5}{6}p_0\right) + \frac{1}{6} \cdot \frac{6}{7}p_0 + \frac{1}{2}p_0$
$\frac{8}{7}p_0 = \frac{8}{42}p_0 + \frac{1}{36} + \frac{5}{36}p_0 + \frac{6}{42}p_0 + \frac{1}{2}p_0$
Collecting the $p_0$ terms on the right with common denominator
$\frac{5}{36} + \frac{1}{7} + \frac{1}{2} = \frac{35 + 36 + 126}{252} = \frac{197}{252}$
And $\frac{8}{7} = \frac{240}{252} + \frac{8}{42} = $ ... Let me collect all $p_0$ terms:
$\left(\frac{240}{252} - \frac{197}{252}\right)p_0 = \frac{1}{36}$
$\frac{43}{252}p_0 = \frac{1}{36} \implies p_0 = \frac{252}{36 \times 43} = \frac{7}{43}$
The complete solution: $p_0 = \frac{7}{43}$, $p_1 = \frac{8}{43}$, $p_{12} = \frac{13}{43}$, $p_6 = \frac{6}{43}$.
Answer: The probability that the process stops because of
, 2, 3$ is$P(1,2,3 \text{ first}) = \frac{7}{43} \approx 0.1628$
Pattern $6, 6$ wins with probability $\frac{36}{43} \approx 0.8372$. The shorter pattern has a decisive advantage.
Intuition
This is a classic pattern-race (or string-competing) problem, and the key insight is that shorter patterns have a structural advantage. Pattern $6, 6$ needs only two consecutive hits, while
, 2, 3$ needs three -- and since each step has the same/6$ probability of advancing, the two-step pattern reaches its absorbing state much faster on average. The result $7/43 \approx 16\%$ reflects this: the three-step pattern is roughly 5 times less likely to win.In quant interviews, pattern-race problems test whether you can build the right state space. The Aho-Corasick / suffix-prefix construction is the general technique: after each new symbol, ask "what is the longest suffix of what I have seen so far that is a prefix of any target pattern?" This gives you the minimal Markov chain. The same idea appears in sequential detection problems in trading -- for example, detecting a specific sequence of order flow events (uptick-uptick-downtick) versus another pattern, and computing which is more likely to trigger first.
- $\langle 1,2 \rangle$: last two rolls were
- There are exactly 4 transient states: no progress ($\emptyset$), last roll was