Problem 700. Monty Hall
The classic Monty Hall "Let's Make a Deal" final showcase puzzle pits the contestant against three Doors. Behind one Door are dream prizes and behind the other two are Donkeys and Chickens.
The contestant picks a Door: 1 2 or 3.
Monty then reveals a Door that is Not the winner.
As the contestant do you stay with your original Door or swap to the other Door?
Your routine will be called twice.
The first time it will see [0 0 0]. You are to select a Door: return an Integer 1,2 or 3.
The second time your function will see [1 2 0] or [1 0 2],if you had selected door number 1. The 2 denotes a revealed Losing Door.
You may now choose Door 1 (no change) or switch to the available door denoted by the zero.
Return an Integer 1, 2, or 3
Example:
Input [0 0 0]
Output 2
Input [0 1 2] % Your first selection is denoted by 1. 2 is a losing Door
Output 1 % This selects Door 1, swapping from Door 2
The Test engine will determine if your final selection is a Winner
The routine will run the game 100 times calling your function twice for every game.
Your Strategy "Passes" if it wins > 50% of the time.
This is the first in a series of planned interactive Games.
This example is also to demonstrate Cody multi-call interactivity capability.
Let's Make a Deal
Solution Stats
Problem Comments
Solution Comments
Show commentsProblem Recent Solvers40
Suggested Problems
-
6425 Solvers
-
The Goldbach Conjecture, Part 2
2364 Solvers
-
Given an unsigned integer x, find the largest y by rearranging the bits in x
1845 Solvers
-
Make a run-length companion vector
642 Solvers
-
364 Solvers
More from this Author308
Problem Tags
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!