Created
February 26, 2012 18:43
-
-
Save samv/1918225 to your computer and use it in GitHub Desktop.
Gambler's win
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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