Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import random
- wins = 0
- losses = 0
- for i in range(1000000):
- # "So you have 3 doors..."
- doors = [0,0,0]
- # doors
- # "One of them is the correct answer"
- doors[random.randrange(0, 3)] = 1
- # doors
- # "You pick one of the doors"
- selection = random.randrange(0, 3)
- # selection
- # "One of the incorrect choices gets removed"
- while len(doors) == 3:
- randomDoor = random.randrange(0, 3)
- # The door only gets removed if it is not a winner and it is not the door the player picked
- if doors[randomDoor] == 0 and randomDoor != selection:
- doors.pop(randomDoor)
- # Shift the player's choice to account for updated indices
- if randomDoor < selection:
- selection -= 1
- # doors
- # "Did I win?"
- if doors[selection] == 1:
- wins += 1
- # "Yes!"
- else:
- losses += 1
- # "No!"
- print "Wins:"
- print wins
- print "\nLosses:"
- print losses
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement