Created
April 11, 2026 06:28
-
-
Save twdamhore/2fd290035c553f4e433d6fb31a3a8077 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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