Skip to content

Instantly share code, notes, and snippets.

@coldfog
Created March 6, 2016 03:59
Show Gist options
  • Save coldfog/1b7dd9b491d45a1c0fb1 to your computer and use it in GitHub Desktop.
Save coldfog/1b7dd9b491d45a1c0fb1 to your computer and use it in GitHub Desktop.
ThreeDoorRewardPuzzle
import random
if __name__ == '__main__':
swap = 0
not_swap = 0
for i in range(1000):
doors = range(4)
reward = random.randint(0, len(doors)-1)
select = random.randint(0, len(doors)-1)
random.shuffle(doors)
for i in doors:
if i != reward and i != select:
doors.remove(i)
break
for i in doors:
if i != select:
left = i
if left == reward:
swap += 1
if select == reward:
not_swap += 1
print 'empty_door', doors
#print 'opened', opened
print 'reward', reward
print 'left', left
print 'select', select
break
print swap
print not_swap
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment