## Let’s Make A Deal!

### July 24, 2009

*Let’s Make A Deal!* was a television game show that originated in the United States in the 1960s and has since been produced throughout the world. In one of the games, prizes were placed behind three doors, and the contestant was asked to pick a door; one door hid an automobile, the other two doors hid goats. Then the host, who knows what is behind the doors, opened one of the doors that the contestant did not pick, revealing in every case a goat, and asks if you want to switch doors. Is it to your advantage to switch your choice of doors?

Your task is to write a program that simulates a large number of games and determines whether or not it is to your advantage to switch doors. What are the odds that you will win the automobile by switching? When you are finished, you are welcome to read or run a suggested solution, or to post your solution or discuss the exercise in the comments below.

Pages: 1 2

I already knew that the correct answer is the probability of winning by switching is 2/3, but:

=> 0.66756

Ugly, but it works.

My Haskell version: http://hpaste.org/fastcgi/hpaste.fcgi/view?id=7478#a7478

Lots of fun – thanks!

-Andy

I suggest also reading a nice treatment of this exact problem in “The man who loved only numbers” by Paul Hoffman.

I’m just now learning Python and figured I’d play around with its list capabilities for this one…

Originally I was using list comprehension to generate a list of random numbers (to indicate which door the car is behind) and keeping the contestant’s choice constant (always picking door number 1), but I realized it might be slightly faster to randomize the contestant’s choice and assume the car is always located behind door number 1 – simply using the list as a looping mechanism.

[...] Let’s Make A Deal! « Programming Praxis. [...]

I made an attempt in PL/SQL (Oracle). I made the number of doors configurable (assuming that the host opens all doors except yours or the prize, or a random single door if you have chosen the prize door initially).

This produces the output

Which produces the following output

Yes, but when the game was played, did the host always open a door? Or did the host, for example, have the discretion to let the original choice go through. Unless we know this, it is meaningless to claim that we know the best strategy for the player.