## Riddler Express

You and I find ourselves indoors one rainy afternoon, with nothing but some loose change in the couch cushions to entertain us. We decide that we’ll take turns flipping a coin, and that the winner will be whoever flips 10 heads first. The winner gets to keep all the change in the couch! Predictably, an enormous argument erupts: We both want to be the one to go first.

What is the first flipper’s advantage? In other words, what percentage of the time does the first flipper win this game?

## Solution

```
from random import random
def flip():
return 1 if random() > 0.5 else 0
= 100000
runs
= 0
nfw for _ in range(runs):
= 0, 0
nah, nbh while(True):
if flip():
+= 1
nah if nah == 10:
+= 1
nfw break
if flip():
+= 1
nbh if nbh == 10:
break
print("Percentage of first person wins: ", nfw/runs)
```