A race between two patterns
A fair coin is tossed repeatedly. Player A wins as soon as the last three tosses read ; player B wins as soon as they read .
What is the probability that A wins?
Fractions, decimals with at least 3 significant digits, and expressions such as sqrt(2)/2, e^-1 or pi/4.
Comparing the average waiting times of the two patterns does not answer the question. Instead, keep track of the longest ending of the toss sequence that is also the start of one of the patterns.
The useful states are: nothing yet, , and . Once you reach , can B still win?
h
s Shown after a correct answer. Revealing it first marks the problem as seen, not solved.
Idea. Only the last few tosses matter, so the game is a Markov chain on the prefixes of the two patterns. One state turns out to be a guaranteed win for A, which makes the system easy to solve.
Step 1: states. Let be the probability that A wins from state , where is the longest end of the toss sequence that is the start of a pattern: , , or .
Step 2: the state HH. After , a head keeps us in (the last two tosses are again ), and a tail completes . B can never win from here, because B needs followed by , and the first ends the game in A's favour. So .
Step 3: the other states.
- From : a head completes (B wins); a tail leaves nothing useful. So .
- From : a head gives , a tail gives . So .
- From : a tail changes nothing, so the game really starts at the first head, and .
Step 4: solve. With : , so , which gives .
A wins with probability .
Why this is not obvious. On its own, takes tosses on average and takes , but waiting times do not decide a race. What matters here is that B's partial progress () can be wiped out by a tail, while A's partial progress () can never be lost.