[Solved] Coin toss/Who wants to be a Billionaire [closed]


writing the simulation is easy – im having trouble figuring out the optimization, i tried .4 to .1 for the pct multiplier and alway made over 1 billion in well less than 1000 tries:

from random import randint

x = 1.0   # 1 euro
pct = .25 # 1/4

for i in range(1000): # 0-999 = 1000
    bet = x * pct
    if randint(0,1) == 1: # assume 0 = tails 1 = heads
        x += bet*2
    else:
        x -= bet

    if x > 1000000000.0:
        break

print i,x

notice i stop once i get to a billion – the numbers get crazy big if you go to 1000 iterations

solved Coin toss/Who wants to be a Billionaire [closed]