Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import random
- from sys import argv
- def hall_old():
- choices = [0]*3
- choices[random.randint(0,2)] = 1
- guess = random.randint(0,2)
- reveal = (random.randint(1,2)+guess)%3 # This gives ~55%
- reveal = 2 - guess # This gives ~44%
- if choices[reveal]==1:
- return hall()
- return choices[3-guess-reveal]==1
- def hall(): # This gives 66%
- choices = [0]*3
- choices[random.randint(0,2)] = 1
- guess = 0
- for i in range(1,3):
- if choices[i]==0:
- reveal = i
- break
- return choices[3-guess-reveal]==1
- def main():
- times = int(argv[1]) # times game is played
- correct = 0
- for i in range(0, times):
- if hall_old():
- correct += 1
- print str(correct * 100 / times) + '%'
- main()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement