Skip to content

Instantly share code, notes, and snippets.

@arisada
Last active June 2, 2020 15:53
Show Gist options
  • Save arisada/64104411bf762597de9441d2039bfdb7 to your computer and use it in GitHub Desktop.
Save arisada/64104411bf762597de9441d2039bfdb7 to your computer and use it in GitHub Desktop.
#!/usr/bin/env python3
import random
change_strategy, stay_strategy = 0, 0
for i in range(1000):
v = [True, False, False]
random.shuffle(v)
print("Solution:", v)
firstchoice = random.choice([0, 1, 2])
print("First choice", firstchoice)
others = [i for i in [0, 1, 2] if i != firstchoice]
if v[firstchoice]:
closed = random.choice(others)
else:
closed = others[1] if v[others[0]] else others[0]
print("closing", closed)
if v[firstchoice]:
print("Stay wins")
stay_strategy += 1
remaining_choices = [i for i in [0, 1, 2] if i != firstchoice and i != closed]
if v[remaining_choices[0]]:
print("Change wins")
change_strategy +=1
print(change_strategy, stay_strategy)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment