Algorithm · Square · Medium
Two players take turns flipping a coin. Each player keeps track of the results of their own flips as a separate sequence, and each player has a distinct target pattern of two consecutive flip outcomes. A player wins as soon as their own target two-flip pattern shows up in their own sequence of flips. The task has three parts: Write a simulation of a single game between the two players. Repeat the simulation a large number of times to estimate how often each player wins.…