Here’s a fun little mathematics problem making the rounds on social media.
Suppose you have two jars, each containing 100 candies. One jar contains only red candies, while the other contains only blue candies. You take 20 candies from the red jar and put them into the blue jar. Then, after mixing everything thoroughly, you randomly select 20 candies from the blue jar and return them to the red jar.
Now comes the question: Are there more red candies in the blue jar, or more blue candies in the red jar?
The answer is that there are exactly the same number of each. Always.
At first glance, this looks like a probability problem. We have random selections, different proportions of candies, and a second selection from a mixed population. We could approach this using probability distributions, perhaps even calculating the expected number of red and blue candies selected.
But that would be a lot of work for something we can prove using one of the simplest techniques in mathematics: mathematical induction.
A Little Mathematical Induction
Mathematical induction is a proof technique that establishes a statement for every positive integer. It consists of two steps.
First, we demonstrate that the statement is true for the number one. This is called the base case.
Second, we demonstrate that if the statement is true for some positive integer , it must also be true for . This is called the inductive step.
Once we have established both, we know the statement is true for every positive integer.
Think of a line of dominoes. We establish that the first domino falls, and then demonstrate that whenever one domino falls, it knocks over the next one. We don’t need to inspect every domino individually.
That’s mathematical induction. And it is extraordinarily powerful.
Back to the Candy
Let’s begin with just one candy rather than twenty.
We take one red candy from the red jar and put it into the blue jar. Then we randomly select one candy from the blue jar and return it to the red jar.
There are only two possibilities.
If we select a red candy, we have simply restored the original arrangement. There are no blue candies in the red jar and no red candies in the blue jar.
If we select a blue candy, there is now exactly one blue candy in the red jar and one red candy in the blue jar.
In either case, the numbers are equal.
We’ve established our base case.
Now suppose the equality holds after exchanges. Can we demonstrate that it must also hold after ?
Yes, and the reasoning is almost embarrassingly simple.
Consider one additional exchange: we send another red candy to the blue jar and receive one candy in return.
If the returned candy is red, nothing changes in the number of misplaced candies. We sent a red candy out and got a red candy back.
If the returned candy is blue, we have added one blue candy to the red jar and left one additional red candy in the blue jar.
In the first case, both counts remain unchanged. In the second, both counts increase by exactly one.
Therefore, if the numbers were equal after exchanges, they remain equal after .
And that’s our inductive step.
There is one small detail worth addressing. The original problem transfers all twenty red candies before returning any. Our proof considers the exchanges as pairs. That’s legitimate because we can pair each returned red candy with one of the red candies originally transferred, and each returned blue candy with one of the transferred red candies that stays behind. We’re simply accounting for the same final arrangement in a different order.
So we have established the base case and the inductive step. By mathematical induction, the equality holds for any positive number of candies exchanged, provided there are enough candies to make the transfers.
Q.E.D.
What Happened to the Probability?
Nothing. We just discovered that it doesn’t matter.
We certainly could calculate the probability of returning any particular number of blue candies. In fact, the number of blue candies returned follows a hypergeometric distribution, something we encounter when sampling from a finite population without replacement.
But that calculation would answer a different question.
Probability tells us how likely we are to find a particular number of misplaced candies. Induction tells us that, regardless of how many there are, the numbers in the two jars must be equal.
This is a stronger conclusion than saying the numbers are equal on average. They are equal in every possible outcome.
Mathematicians call a property that remains unchanged under some operation an invariant. In this problem, the difference between the number of red candies in the blue jar and blue candies in the red jar is invariant. It starts at zero and remains zero after every exchange.
And here’s something else: we never needed 100 candies. We didn’t need twenty, either. We didn’t even need the jars to contain equal numbers of candies initially.
The result depends only on the jars starting with different colors and exchanging equal numbers of candies.
The Importance of Asking the Right Question
This is what makes the problem interesting to me.
Its presentation invites us to think about randomness. We see two populations, a mixing process, and a random sample, so naturally we reach for probability.
But the problem is not fundamentally about randomness. It is about a relationship that cannot change, regardless of the randomness.
Recognizing that distinction turns a seemingly complicated problem into a straightforward proof.
And that is an important lesson in mathematics. Sometimes the challenge isn’t finding the right formula or knowing how to perform a difficult calculation. Sometimes it’s recognizing that the calculation isn’t necessary in the first place.
Twenty candies, two jars, and a proof by induction.
Not bad for a social media puzzle.