Skip to content

Instantly share code, notes, and snippets.

@samv
Created February 26, 2012 18:43
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save samv/1918225 to your computer and use it in GitHub Desktop.
Save samv/1918225 to your computer and use it in GitHub Desktop.
Gambler's win
import random
cups = 3
i = 0
keeping_wins = 0
changing_wins = 0
while i < 1000:
i += 1
winning_cup = random.randint(1,cups)
#first_pick = random.randint(1,cups)
first_pick = 2
while True:
host_pick = random.randint(1,cups)
if host_pick != first_pick and host_pick != winning_cup:
break
if first_pick == winning_cup:
keeping_wins += 1
else:
changing_wins += 1
print "Keeping won {keep} times, changing won {change} times".format(
keep=keeping_wins,
change=changing_wins,
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment