The puzzle is stated as follows:

Suppose you’re on a game show, and you’re given the choice of three doors. Behind one door is a car, behind the others, goats. You pick a door, say #1, and the host, who knows what’s behind the doors, opens another door, say #3, which has a goat. He says to you, "Do you want to pick door #2?" Is it to your advantage to switch your choice of doors?

Now before you read further, you should stop here and try finding your own logic.

My way of looking at it is here: Assume that the game was played 3000 times. I am taking number in thousands to get statistically near correct answer in case you also plan to write a program. If the participant selects #1 for all the 3000 trials, he will win 1000 times out of 3000 trials (1 car, 3 doors, so probability of getting car behind a particular door is 1/3). And will lose 2000 times (2 goats and 3 doors, so probability of getting a goat is 2/3). When participant loses 2000 times, it means that for all those 2000 instances, the car was hidden behind either #2 or #3. So if the host says that there is goat behind #3, the participant should have switched from #1 to #2 to win chances from these 2000 lost chances (as staying on #1 can only give max 1000 wins) and when host says that goat is behind #2, the participant should have switched from #1 to #3 to win chances from these 2000 lost chances (as staying on #1 can only give max 1000 wins). Ideally, if the participant switches every time after the host has given the hint, he will win 2/3 of the times.

pymontyhall.py is a quick program for you to download and verify it on computer. It is written in Python so a Linux or Mac machine should be able to run it without any extra software but on Windows machine, you will need to install python. Run the program from terminal as:

**python**

**pymontyhall.py**. Output of the program will appear like this:

...

Trial: 2997, arrangement: ['Car', 'Goat', 'Goat'], door selected: #3, result: lose, total hit: 1985 and total miss: 1012

Trial: 2998, arrangement: ['Goat', 'Car', 'Goat'], door selected: #2, result: win, total hit: 1986 and total miss: 1012

Trial: 2999, arrangement: ['Goat', 'Car', 'Goat'], door selected: #2, result: win, total hit: 1987 and total miss: 1012

When switching, winning probability:0.662333, losing probability:0.337667