The puzzle about a car and two goats
A collegue of mine gave me the following puzzle to solve:
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 number 1, and the host, who knows what’s behind the doors, opens another door, say number 3, which has a goat. He says to you, “Do you want to pick door number 2?” Is it to your advantage to switch your choice of doors?
In the evening I wrote a simple console application that proves the solution practically running the game 10000 times. You can compile it in command line “csc.exe GoatSelector.cs” and execute GoatSelector.exe.
The application shows you validation of the .NET random engine first. There are percentages of 0, 1, 2 numbers got from the Random class executed for 10000 times. Then it shows percentage of success when you “pick door number 2” (switching your choice) and percentage of success when you stay with your first selected door. Download the code
No comments yet.
Leave a comment
-
Recent
- Remote desktop via VPN from SUSE 11.1
- EVPO DC project structure
- EVPODC Getting Started Part 2 (Configuration)
- EVPODC getting started part 1 (installation)
- Customize property editor in the VS designer
- How to load referenced assemblies from any place you want
- The puzzle about a car and two goats
- Effect of XML:Space=”preserve”
- regular expressions for XML tags
-
Links
-
Archives
- May 2009 (2)
- November 2008 (2)
- June 2008 (5)
-
Categories
-
RSS
Entries RSS
Comments RSS