Simulating the Two-Heads-in-a-Row Puzzle in 20 Lines of Python
You flip a fair coin until you get two heads in a row. How many flips does it take, on average? Most people say 4. It feels right: two flips for HH would be 4 if you somehow "double" a 50/50 wait.
- Simulation confirms expected 6 flips for two consecutive heads
- Python code defines function to track coin flip streaks
- Streak resets to 0 after tails, lengthening wait time