The Monty Hall Paradox December 19, 2008Posted by gcorbin in C#, Commentary.
Tags: Software Puzzles
add a comment
Every now and then, I find myself missing the simplistic days of higher education. I miss the enjoyment of studying computational theory and all those fun brainteaser puzzles that such topics often bring to light. Recently, while reading one of my favorite blogs (blog.stackoverflow.com), I can across a posting / podcast that had references to a few such puzzles. Some of these puzzles I’ve already heard of, but there was one that I’ve never come across. It s called “The Monty Hall Paradox”.
The puzzle is about an old game show where the host (Monty Hall), would give contestants a choice of 3 doors. One of the doors would have a new car and the other 2 would have a goat. The contestant would choose 1 door, then Monty would open 1 of the other 2 remaining door revealing a 1 of the goats. He would then give the contestant the option to keep their selected door or switch doors. So the question is would it be best to keep your original door or switch doors?
So, my first answer to this is that it doesn’t matter. 2 doors remaining should be a 50/50 chance. This is what most people give for an answer to this puzzle also. However, after studying it further it became apparent that the answer was not this simple. Several other people are posting the true answer is that its better to switch doors. The odds of getting the car by switch doors are 66%. So, instead of just reading more and more on the topic, I decide to write a simple program that I could use to test this out.
I wrote the code in .NET (of course). It’s a small program 30 lines or less. I ran the code over 1 million iterations and to my surprise, the odds were 66.34% of getting car if the program swaps doors at the end.
Check out the code. Check out addition puzzles and feel free to share.
Find more on the monty hall puzzle here.