During my internship at IBM Research this summer, my office mate Renbo and I discussed the following extremely important research problem.
There are twelve men on an island. Eleven weigh exactly the same amount, but one of them is slightly lighter or heavier. You must figure out which. The island has no scales, but there is a see-saw. The exciting catch: you can only use it three times.
To clarify: the riddle is asking us to find the odd-weight islander, but we do not need to determine whether the odd-weight islander is lighter or heavier.
Instead of solving this riddle, we’re going to take the riddle-writer’s perspective: what is the maximum number of islanders such that the riddle is solvable? Along the way, we’ll uncover some hints about to approach the original riddle.
Suppose we have islanders and are allowed weighings on the see-saw. We ask: under what conditions on and is the riddle solvable? (In the original riddle, and .) There are two sorts of conditions we might look for.
- A sufficient condition on and is one such that if the condition holds, the riddle is solvable.
- A necessary condition on and is one such that if the condition fails, the riddle is unsolvable.
The way to prove that a condition is sufficient is pretty intuitive: given the condition, find a solution! For example, solving the original riddle shows that is a sufficient condition. Of course, as those who paused the Brooklyn 99 episode to try out the riddle quickly found out, finding the solution can still be tricky. But the overall approach to proving a sufficient condition is clear.
Necessary conditions are more difficult. To prove that a condition is necessary, we have to show that if the condition fails, then there does not exist any islander-weighing strategy that solves the riddle. For example, suppose we want to prove that the puzzle is impossible for islanders in weighings. It’s not enough to take a solution that finds the odd-weight islander for and demonstrate that it fails for . Instead, we need to somehow consider every islander-weighing strategy.
In this post, we will find a necessary condition on and for the puzzle to be solvable. Specifically, we’ll prove that the puzzle is solvable only if
To do so, we’ll use information theory, a branch of mathematics that helps us prove necessary conditions like this without explicitly considering every possible islander-weighing strategy.
The Short Version
We’re going to start by proving a slightly weaker necessary condition: the puzzle is solvable only if (note the non-strict inequality). Proving this weaker condition introduces all the key ideas without using any information theory.
We begin by observing that if the riddle is solvable, then it is solvable with a deterministic strategy (see Appendix,), so we can restrict our attention to deterministic strategies.
Suppose the riddle asked us to both find the odd-weight islander and determine whether they are lighter or heavier. To solve this modified riddle, we need to distinguish between the possible scenarios: there are possibilities for the odd-weight islander, and they are either lighter or heavier. Each see-saw weighing has three possible outcomes: the left side is heavier, the right side is heavier, or the sides are balanced. So there are possible outcomes of a sequence of weighings. After observing one of these outcomes, we should be able to unambiguously determine which of the scenarios we are in. We can’t do this if there are fewer outcomes than scenarios. This means is a necessary condition to solve the modified riddle.
The original riddle asks us just to find the odd-weight islander, so it seems like we only have to distinguish between possible scenarios. But it turns out that, even if we’re not trying to, we almost always end up figuring out whether the odd-weight islander is lighter or heavier. To see why, suppose we figure out that Charles is the odd-weight islander. If we ever put Charles on the see-saw in the process, then we see whether Charles was on the lighter or heavier side of the see-saw. This means the only way we can find the odd-weight islander without finding out whether they are lighter or heavier is if we never weigh the odd-weight islander.
Given an islander-weighing strategy, we say an islander is “lonely” if whenever they are the odd-weight islander, our strategy never weighs them. It turns out that any successful strategy can have at most one lonely islander (see Appendix,). This means that to solve the riddle, we must distinguish between at least possible scenarios:
- a single scenario in which the odd-weight islander is the lonely islander, and
- scenarios in which the odd-weight islander is one of the non-lonely islanders.
There are still possible outcomes of weighings, so is a necessary condition to solve the riddle.
A Stricter Condition
Let’s think about what the condition says about the original riddle. Could we solve it with fewer weighings? How about more islanders?
- Given , we must have , which means we need , so the riddle cannot be solved in fewer weighings.
- Given , we must have , which means . So the riddle might be solvable with more islanders.
It turns out that the riddle is solvable for but not . But we could rule out using the necessary condition (note the strict inequality) that we promised in the introduction. Proving this stricter condition is where the information theory comes in.
How Much Information is in Each Weighing?
One of the key insights of information theory is to draw a connection between information and randomness. Information theory views anything we don’t know as a random variable. The entropy of a random variable tells us, roughly speaking, how much information we expect to gain by learning the outcome of that random variable. For brevity, I’m not going to explain in detail how to define entropy, instead explaining just the bits we need for this post. (If you’re curious, sources like Wikipedia have pretty good explanations.)
In our context, the main random variable we want to know is which of the scenarios we are in. Let’s give it a name:
If each of the scenarios is equally likely, then has entropy .
Solving the riddle entails learning the outcome of , but we never observe directly. Instead, we observe the results of each weighing. These weighing outcomes are also random variables, so let’s write
Let’s call the possible outcomes of a weighing , , and for tipping left, tipping right, and staying balanced, respectively. Writing for the probability mass function of (meaning, for example, that is the probability that the see-saw tips left on the third weighing), we can write the entropy of as
To solve the riddle, it must be that the amount of information we get from the weighings is at least the amount of information we would get by directly learning which scenario we are in. That is, a necessary condition for the riddle to be solvable is
(To be precise, the amount of information we learn from the th weighing is never more than , but might be less if later weighings tell us information we already learned from earlier weighings. Look up conditional entropy for details.)
Our question thus becomes: how do we maximize , the entropy of the th weighing? It turns out that the entropy of a random variable is maximized when all of its outcomes are equally likely. In the case of , this happens when each outcome has probability , so . Plugging this bound into , we get necessary condition
… which is equivalent to the weaker necessary condition we already derived. What’s missing?
To get the stricter condition, we need one last observation: we can’t actually make the three outcomes of each weighing equally likely! Suppose that in the first weighing we put islanders on each side of the see-saw. The probability of each outcome is
That is, of the scenarios, there are that would make the see-saw tip left: where someone on the left is heavier and where someone on the right is lighter. (Remember that, by definition, the lonely islander is not on the see-saw.) But we cannot possibly have , because is even and is odd. So we can’t make the three outcomes equally likely, which means . Plugging this bound into , we get necessary condition
which is equivalent to , as desired.
Here are a few of the details we skipped above. The proofs don’t use any fancy techniques, so they make good exercises if you can resist peeking.
If the riddle is solvable, then it is solvable with a deterministic islander-weighing strategy.
Suppose we have a nondeterministic islander-weighing strategy solves the riddle. That means when we get to a nondeterministic step, we choose between one of several options for to proceed. But our strategy always works, which means it should work no matter which option we pick. In particular, it still works if we always arbitrarily pick the first option, which makes our strategy deterministic.
Any deterministic islander-weighing strategy that solves the riddle has at most one lonely islander.
Recall that an islander is “lonely” for a given strategy if whenever they are the odd-weight islander, they are not placed on the see-saw. We’re going to show that if a strategy has a lonely islander, then none of the other islanders are lonely. Say that Jake is the lonely islander and consider Charles, another islander. We need to show that if Charles is the odd-weight islander, then we have put Charles on the see-saw at least once.
The key is this: because Jake is lonely, we can’t put Jake on the see-saw until we get at least one unbalanced weighing. This is because until we see an unbalanced weighing, Jake could still be the odd-weight islander.
Suppose now that Charles is the odd-weight islander. If we never put Charles on the see-saw, then all the weighings are balanced. But because all the weighings are balanced, we must never have put Jake on the see-saw. Because neither Jake nor Charles have been weighed, we cannot possibly tell the difference between them. Therefore, to solve the riddle, if Charles is the odd-weight islander, our strategy must at some point put Charles on the see-saw.