Skip to content

Instantly share code, notes, and snippets.

@twdamhore
Created April 11, 2026 06:28
Show Gist options
  • Select an option

  • Save twdamhore/2fd290035c553f4e433d6fb31a3a8077 to your computer and use it in GitHub Desktop.

Select an option

Save twdamhore/2fd290035c553f4e433d6fb31a3a8077 to your computer and use it in GitHub Desktop.
import random
sample_size = 10_000
stay_wins = 0
switch_wins = 0
for _ in range(sample_size):
prize = random.randint(1, 3)
pick = random.randint(1, 3)
# Host reveals an empty door (not the prize, not your pick)
remaining = [d for d in [1, 2, 3] if d != pick and d != prize]
host_opens = random.choice(remaining)
if pick == prize:
stay_wins += 1 # Staying wins when original pick was right
else:
switch_wins += 1 # Switching wins every other time
print(f"Stay: {stay_wins}/{sample_size} wins ({100 * stay_wins / sample_size:.2f}%)")
print(f"Switch: {switch_wins}/{sample_size} wins ({100 * switch_wins / sample_size:.2f}%)")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment