← All posts
November 15, 2026 · 2 min read

The Monty Hall problem, explained by playing out every case

Three doors, one car, the host opens a goat. Lay out every case where the car can be and see why switching wins 2 times out of 3.

This is the Monty Hall problem. You're on a game show, and there are three doors. Behind one is a car; behind the other two are goats. You pick door 1. The host, who knows where the car is, opens door 3 and shows you a goat. Then he asks: do you want to switch to door 2?

Three doors, your pick on door 1, the host has opened door 3 to show a goat

Most people say it doesn't matter. Two doors are left, so it feels like fifty-fifty. It isn't. If you switch, you win the car 2 times out of 3.

That answer famously annoyed a lot of mathematicians when it was first published, so let's not argue about it. Let's play it out.

An arrow from door 1 to door 2 asking: switch?

The rules that matter

Two rules make this puzzle work, and both are easy to miss:

  1. The host knows where the car is.
  2. He always opens a door you didn't pick, and it always has a goat behind it.

He is never guessing. That's the whole trick.

Play out every possibility

Before you choose, the car is equally likely to be behind door 1, door 2 or door 3. So there are exactly three cases. You always start by picking door 1. Here is what happens in each one.

Three rows of doors, one for each place the car can be, with the contents visible

The car is behind door 1. You picked right. The host opens either of the other doors, since both hide goats. If you stay, you win. If you switch, you lose.

The car is behind door 2. The host can't open door 2 (that's the car) and can't open door 1 (that's yours). He has to open door 3. The only closed door left is door 2, so switching wins.

Car behind door 2: the host must open door 3, so switching to door 2 wins

The car is behind door 3. Same thing the other way round: he has to open door 2, and switching to door 3 wins.

Count the cases

All three cases played out: stay wins 1 of 3, switch wins 2 of 3

Out of three equally likely cases, staying wins one and switching wins two.

Car behind 1 Car behind 2 Car behind 3 Wins
Stay car goat goat 1 of 3
Switch goat car car 2 of 3

Why, in one sentence

Switching wins whenever your first pick was wrong, and your first pick is wrong 2 times out of 3.

The host's choice is what makes this happen. When your first pick is a goat, he is forced to open the other goat, which leaves the car as the only door to switch to. His move carries information; a random door opening wouldn't.

Check it with code

You can count the cases exactly, then confirm with a simulation:

from fractions import Fraction
import random

stay = switch = 0
for car in (1, 2, 3):                              # the three equally likely cases; you pick door 1
    opened = next(d for d in (2, 3) if d != car)   # the host opens a goat door you didn't pick
    other = ({1, 2, 3} - {1, opened}).pop()
    stay += car == 1
    switch += car == other
print('stay', Fraction(stay, 3), 'switch', Fraction(switch, 3))

rng = random.Random(1)
n = 100_000
wins = sum(rng.randrange(3) != rng.randrange(3) for _ in range(n))
print(f'simulated switch: {wins / n:.3f}')

Output:

stay 1/3 switch 2/3
simulated switch: 0.667

The simulation uses the same sentence as above: switching wins exactly when the car isn't behind your first pick.

Try it

Make it 100 doors. You pick one, and the host, who knows where the car is, opens 98 goats. Would you keep your door, or switch to the one he left shut? Count the cases the same way: how often does switching win?