insideout Get Pro

12 · Interview puzzles, worked

Pro

Probability, lesson 12

Interview puzzles, worked

Classic interview puzzles, solved step by step.

Interview puzzles look like tricks, but each one gives way to a method you've already met. This lesson works four classic puzzles step by step and names the method behind each, so you can use it on the new versions you'll be asked. You need conditional probability, expected value and the complement.

By the end, you can:

  1. Solve the three doors puzzle by asking how the host picks a door.
  2. Find the average wait for a pattern of flips, with one equation per state.
  3. Find an average count by giving each piece a score of 1 or 0.
  4. Find the chance of a match by counting the ways there's none.

Part 1. Ask how the news was chosen

Solve the three doors puzzle by asking how the host picks a door.

A prize is behind one of three doors. You pick one. The host, who knows where the prize is, opens one of the other two to show it's empty, and offers you a switch to the last closed door. Two doors are left, so it looks like 50:50. It isn't.

Example 1.1

Three doors

You pick door 1. The host opens an empty door from the other two, never the one with the prize. Should you switch to the door the host leaves shut?

  1. Split on where the prize isdoor 1, 2 or 3, chance 1/3 each

    Your pick doesn't move the prize.

  2. Prize behind door 1switching loses: 1/3

    The host can open either other door. Both are empty, and switching takes you off the prize.

  3. Prize behind door 2 or 3switching wins: 2/3

    The host must open the other empty door, so the door left shut has the prize.

AnswerSwitch. It wins 2/3 of the time, and staying wins 1/3.

Your first pick is right 1 time in 3, and the host's move can't change that: there's always an empty door to open. When your pick is wrong, the host's rule forces the prize onto the one door left shut. So switching wins exactly when your first pick was wrong, 2 times in 3.

You pick door 1. The host opens an empty one. 1 2 3 you Prize behind 1 switch loses Prize behind 2 switch wins Prize behind 3 switch wins Each case 1/3: switching wins 2/3
You pick door 1. 1 2 3 you Prize: 1 switch loses Prize: 2 switch wins Prize: 3 switch wins Each case 1/3: switching wins 2/3
Figure 1You pick door 1. In each of the three equally likely cases, the host opens an empty door you didn't pick. Switching wins in the two cases where your first pick was wrong.

The Monty Hall problem

The Monty Hall problem is the usual name for the three doors puzzle. Its method reaches far past game shows: before you update on news, ask how the news was chosen. The same open door means different things under different rules.

Change the rule and the answer changes. Suppose the host doesn't know where the prize is, opens one of the other doors at random, and it happens to be empty. That rules out the case where the prize was behind it, and the two cases left are equally likely: switching wins 1/2. Same door, different news.

Your turn

The same game with 100 doors. You pick one, and the host opens 98 empty ones. Switching wins with chance:

Your first pick is right 1 time in 100. The other 99 doors hold the prize the rest of the time, and the host has opened every one of them except the one it has to be behind.

Part 2. Name the states

Find the average wait for a pattern of flips, with one equation per state.

Keep going with Pro

You've done the first part. Pro opens the rest of this lesson, and every other one.

Still to come
  1. Name the states
  2. Add up small pieces
  3. Count the complement

Probability overviewSpotted a mistake? Tell us.