Created
May 16, 2011 16:53
-
-
Save falsetru/974828 to your computer and use it in GitHub Desktop.
차,염소,염소
This file contains 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 | |
def simul1(): | |
rooms = [0, 0, 1] | |
random.shuffle(rooms) | |
i = random.randrange(3) # initial | |
while True: | |
j = random.randrange(3) # goat | |
if j != i and rooms[j] == 0: | |
break | |
k = ({0, 1, 2} - {i, j}).pop() | |
return rooms[k] == 1 # switch | |
tries = 100000 | |
wins = sum(simul1() for i in range(tries)) | |
print(float(wins) / tries) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment