Riddler Express
You have one token, and I have two tokens. Naturally, we both crave more tokens, so we play a game of skill that unfolds over a number of rounds in which the winner of each round gets to steal one token from the loser. The game itself ends when one of us is out of tokens — that person loses. Suppose that you’re better than me at this game and that you win each round two-thirds of the time and lose one-third of the time.
What is your probability of winning the game?
Solution
from random import random
= 100000
runs = 0
cnt for _ in range(runs):
= 1, 2
me, you while(you != 0 and me != 0):
if random() <= 2/3:
-= 1
you += 1
me else:
+= 1
you -= 1
me if you == 0:
+= 1
cnt print(cnt/runs)
The probability of me winning the game is \(.57\).