Protect the Treasure

Nine pirates have captured a treasure chest. In order to protect it, they decide to lock it using multiple locks and distribute several keys for each of these locks among them, so that the chest can be opened only by a majority of the pirates. What is the minimum number of keys each of the pirates should get?

First, we show that for every four pirates, there exists a lock which cannot be opened only by them and can be opened by everyone else. We choose an arbitrary group of four pirates. If they can open every lock, then they can access the treasure without the need of a majority. If any of the remaining pirates cannot open that lock, then he, together with the initial group of four still cannot access the treasure. Thus, the claim is proved and to each group of four pirates we can assign a unique lock. These are \binom{9}{4}=126 locks in total. Finally, every pirate should get keys for \binom{8}{4}=70 of these locks, one for each group of four additional pirates he can be a group of.

How Many Times on Average?

A common type of questions which appears on Quant Interviews is:

“You have a sequence of random variables. How many times on average does a certain outcome appear in this sequence?”

Here are a few examples:

  1. You are throwing a coin 100 times. How many times will you encounter the Heads-Heads-Tails in this sequence?
  2. Five husbands and five wives have sat around a circle table in random order. What is the average number of spouses which are sitting next to each other?

While such problems can be solved using induction, there is another, more elegant approach. It is based on the following observation:

The average number of successful events is equal to the sum of the probabilities that each of these events is successful. The events do NOT need to be independent.

Written mathematically, this translates to:

\mathbb{E}(\|\{X_i = 1, 1 \leq i \leq n \}\|) = \mathbb{E}(\sum_{i=1}^{n} X_i) = \sum_{i=1}^{n} \mathbb{E}(X_i) = \sum_{i=1}^{n}\mathbb{P}(X_i =1),

where X_i is a random variable, such that X_i=1 if the i-th event is successful X_i = 0 otherwise.

  • The first equation follows from the definition of X_i.
  • The second equation follows from linearity of expectation.
  • The third equality is a basic property of expectation.

Let us see how to apply this technique to solve the coin question posed above.

We define a random variable X_i which is equal to 1 if and only if coin tosses i, i+1, i+2 are Tails-Tails-Heads respectively. We have:

\mathbb{E}(\|\{X_i=1, 1\leq i \leq 100\}\|) = \sum_{i=1}^{100}\mathbb{P}(X_i=1)

It is easy to see that for each 1\leq i \leq n, X_i = \frac{1}{2}\times\frac{1}{2}\times\frac{1}{2}=\frac{1}{8}. Therefore, the answer to the problem is 100\times \frac{1}{8}=12.5.


To solve the second problem, we define a random variable X_i which is equal to 1 if and only a husband and his wife are sitting on spots i and i+1 around the table. For each i the probability of this happening is equal to \frac{1}{9}. Indeed, no matter who sits on spot i, the chance that their spouse sits on spot i+1 is 1:9. Therefore, the average number of spouses sitting next to each other is:

\mathbb{E}(\|\{X_i=1, 1\leq i \leq 10\}\|) = \sum_{i=1}^{10}\mathbb{P}(X_i=1)=10\times\frac{1}{9}=1\frac{1}{9}

As we can see, the presented technique is a simple, but very powerful tool. For extra practice, try to solve this fun puzzle from our blog on your own:

Buried Up to Neck

Three friends, Adam, Bob, and Charlie are buried in the sand up to their necks, all facing West. Charlie can see both Adam and Bom, Bom can see only Adam, and Adam cannot see anyone. Black and white hats are placed on their heads. The three friends are told that there is at least one hat from each color, and then they are asked whether anyone can guess the color of their own hat.

After a few minutes, one of them answers. Who is that?

If Adam and Bob had hats with identical colors, then Charlie would immediately be able to deduce that his hat has the opposite color. Charlie doesn’t do that, so Adam and Bob are able to figure out that their hats have opposite colors. Since Bob is the one who can see the color of Adam’s hat, he is the one that answers the question.

Fish Eat Fish

A hundred fish are swimming along a stream at different velocities. If one fish catches up to another fish, it eats it and continues swimming. What is the expected number of fish that will survive?

Notice that the N-th fish in the stream survives if and only if it is the fastest among the first N fish. The probability of this event happening is equal to 1/N. Since the expected number of fish that survive is equal to the sum of the survival probabilities for each of them, the answer is 1+1/2+1/3+…+1/N.

For more details on the last claim, consider reading our blog post “How Many Times on Average?”

Worm in an Apple

There is a perfectly spherical apple with a radius 50mm. A worm has entered the apple, made a tunnel of length 99mm through it and left. Prove that we can slice the apple in two pieces through the center, so that one of them is untouched by the worm.

Let the entering point is A, the leaving point is B and the center of the apple is C. Consider the plane P containing the points A, B and C and project the worm’s tunnel on it. Since 99 < 2×50, the convex hull of the tunnel’s projection will not contain the center C. Therefore we can find a line L through C, such that the tunnel’s projection is entirely in one of the semi-planes of P with respect to L. Now cut the apple with a slice orthogonal to P passing through the line L and you are done.