Compute win probability in coin-toss game
Morgan StanleyData Scientist · Technical ScreenLast updated
This question evaluates understanding of probability theory and stochastic processes, focusing on win probability in an alternating coin-toss game and reasoning about pattern occurrence and stopping times in random sequences.
Two players, A and B, play the following game with a fair coin:
- They toss the coin alternately: A tosses first, then B, then A, then B, and so on.
- The sequence of results (H for heads, T for tails) is recorded in order.
- The game ends as soon as the subsequence "HT" (a head immediately followed by a tail on the next toss) appears for the first time.
- The person who tosses the tail in this first "HT" subsequence wins the game.
Assuming the coin is fair and the game continues indefinitely until it ends, what is the probability that player A wins the game?
Solution walkthrough is for members
Get the full walkthrough with reference code and complexity analysis, plus Kitty Coach at 300 messages a day. Hints, the code runner and community answers stay free.