# Betting Strategy
def betting(j,s):
if j == 4:
if s >= 5:
return (1,’Done’)
else:
return (0,’Done’)
else:
return max((.4*betting(j+1,s+a)[0]+.6*betting(j+1,s-a)[0],a)
for a in range(s+1))
# betting(1,2) = .256
# Game 1 – bet $2
# Game 2 – bet $1
# Game 3
# – If won Game 2, bet $0 in Game 3
# – If lost Game 2, bet $3 in Game 3
p = .1
def parking(j):
if j == 0:
return 1/p # https://en.wikipedia.org/wiki/Geometric_distribution
else:
return p*min(j-1,parking(j-1)) + (1-p)*parking(j-1)