• API
• FAQ
• Tools
• Archive
SHARE
TWEET

# Untitled

a guest Jun 26th, 2019 63 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
1. import random
2. from sys import argv
3.
4. def hall_old():
5.     choices = [0]*3
6.     choices[random.randint(0,2)] = 1
7.     guess = random.randint(0,2)
8.     reveal = (random.randint(1,2)+guess)%3 # This gives ~55%
9.     reveal = 2 - guess # This gives ~44%
10.     if choices[reveal]==1:
11.         return hall()
12.     return choices[3-guess-reveal]==1
13.
14. def hall(): # This gives 66%
15.     choices = [0]*3
16.     choices[random.randint(0,2)] = 1
17.     guess = 0
18.     for i in range(1,3):
19.         if choices[i]==0:
20.             reveal = i
21.             break
22.     return choices[3-guess-reveal]==1
23.
24. def main():
25.     times = int(argv[1]) # times game is played
26.     correct = 0
27.     for i in range(0, times):
28.         if hall_old():
29.             correct += 1
30.     print str(correct * 100 / times) + '%'
31.
32. main()
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy.

Top