-
Notifications
You must be signed in to change notification settings - Fork 0
/
MontyHall.py
34 lines (29 loc) · 993 Bytes
/
MontyHall.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
import random
class Game:
def rungame(self, game):
car = random.randint(1,3)
guess = random.randint(1,3)
if car == guess:
d = [1,2,3]
d.remove(car)
reveal = random.choice(d)
else:
d = [1,2,3]
d.remove(car)
d.remove(guess)
reveal = d[0]
if game == "stick": #What happens if we stick
if guess == car:
return(1) #If we win return a 1
else:
return(0) #If we loose return 0
else: #What happens if we switch
d = [1,2,3]
d.remove(reveal)
d.remove(guess) #Remove our current guess
if d[0] == car:
return(1) #If we win return a 1
else:
return(0) #If we loose return 0
if __name__ == '__main__':
print "I can't run on my own"