*Welcome to techInterview, a site for technical interview questions, brain teasers, puzzles, quizzles (whatever the heck those are) and other things that make you think!*

Another well known problem in probability is the Monty Hall problem.

You are presented with three doors (door 1, door 2, door 3). one door has a million dollars behind it. the other two have goats behind them. You do not know ahead of time what is behind any of the doors.

Monty asks you to choose a door. You pick one of the doors and announce it. Monty then counters by showing you one of the doors with a goat behind it and asks you if you would like to keep the door you chose, or switch to the other unknown door.

Should you switch? If so, why? What is the probability if you don’t switch? What is the probability if you do.

Lots of people have heard this problem.. so just knowing what to do isn’t sufficient. its the explanation that counts!

### Solution

another well known problem in probability is the monty hall problem.

you are presented with three doors (door 1, door 2, door 3). one door has a million dollars behind it. the other two have goats behind them. you do not know ahead of time what is behind any of the doors.

monty asks you to choose a door. you pick one of the doors and announce it. monty then counters by showing you one of the doors with a goat behind it and asks you if you would like to keep the door you chose, or switch to the other unknown door.

should you switch? if so, why? what is the probability if you don’t switch? what is the probability if you do.

lots of people have heard this problem.. so just knowing what to do isn’t sufficient. its the explanation that counts!

the answer is that yes, you should *always* switch as switching increases your chances from 1/3 to 2/3. how so, you ask? well, lets just enumerate the possibilities.

door 1 door 2 door 3

case 1 $$ goat goat

case 2 goat $$ goat

case 3 goat goat $$

its clear that if you just choose a door and stick with that door your chances are 1/3.

using the switching strategy, let’s say you pick door 1. if its case 1, then you lose. if it’s case 2, monty shows you door 3, and you switch to door 2, you win. if it’s case 3, monty shows you door 2, and you switch to door 3, you win. it doesn’t matter what door you pick in the beginning, there are always still three possibilities. one will cause you to lose, and two will cause you to win. so your chances of winning are 2/3.

the solution all resides in the fact that monty knows what is behind all the doors and therefore always eliminates a door for you, thereby increasing your odds.

maybe its easier to see in this problem. there are 1000 doors, only one of which has a prize behind it. you pick a door, then monty opens 998 doors with goats behind them. do you switch? it seems more obvious in this case, because monty had to take care in which door not to open, and in the process basically showing you where the prize was (999 out of 1000 times).