Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

Problem 700. Monty Hall

Created by Richard Zapor

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


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

Problem Group

Solution Statistics

40 correct solutions 48 incorrect solutions
Last solution submitted on Sep 11, 2014