A problem circulating on social media starts with two jars of candy. One contains 100 red candies and the other contains 100 blue candies. We move 20 red candies into the blue jar, mix them up, and then randomly select 20 candies to return to the red jar. The problem asks whether we end up with more red candies in the blue jar or more blue candies in the red jar.
The answer is that the two numbers are exactly equal. It does not matter which 20 candies we select for the return trip, or even whether the selection is random. This is an interesting problem because it is presented as though we should be calculating probabilities. The blue jar, after receiving the red candies, contains 120 candies of two colors. We could use a hypergeometric distribution to describe the random selection from that jar, but that would tell us how many blue candies we are likely to return, not whether the two jars have equal numbers of misplaced candies.
For that, I think mathematical induction is a much simpler approach.
Start with One Candy
Mathematical induction establishes a proposition for all positive integers by demonstrating two things. First, the proposition is true for the number one, the base case. Second, if it is true for some positive integer , then it must also be true for , the inductive step. Prove both and we have established the proposition for every positive integer for which the operation is defined.
We can start the candy problem with just one candy rather than twenty. Move one red candy to the blue jar and select one candy from that jar to bring back. If the candy returned is red, both jars are back where they started, with no candies of the wrong color in either. If the candy returned is blue, there is one red candy in the blue jar and one blue candy in the red jar. Those are the only possible outcomes and the two counts are equal in both. That is our base case.
Now suppose we have made exchanges, each consisting of sending one red candy to the blue jar and returning one candy to the red jar. Assume that after those exchanges the number of red candies in the blue jar equals the number of blue candies in the red jar. To make one more exchange, we send another red candy to the blue jar and take one candy back.
If the returned candy is red, the extra red candy is removed from the blue jar and neither of the two counts changes. If the returned candy is blue, the additional red candy stays in the blue jar and an additional blue candy enters the red jar. Both counts increase by one. Accordingly, if the counts are equal after exchanges, they must remain equal after exchanges.
That establishes the inductive step. Combined with the base case, it proves the equality for any positive number of these exchanges, provided we have enough red candies to make them.
The Order of the Transfers
There is a small complication here worth addressing. The original problem does not describe twenty separate exchanges. We move all twenty red candies at once and then return twenty candies at once. Those are not the same random experiment. If we return a candy after each red candy is added, the composition of the blue jar changes differently than if we add all twenty first. This would matter if we were actually trying to calculate probabilities.
But we’re not calculating probabilities. We’re accounting for the candies that have changed jars. Take any particular collection of twenty candies returned in the original problem and pair them, in any order, with the twenty red candies that were transferred out. Every pair consists of a red candy going out and either a red or blue candy coming back. A red-for-red pair leaves no candy of the wrong color in either jar. A red-for-blue pair leaves one red candy in the blue jar and puts one blue candy in the red jar. The final counts depend on the pairs, not the order in which the jars were filled and emptied. So the inductive argument applies to the original problem as well.
In mathematics, we call this an invariant, a property that remains unchanged through an operation. Here the invariant is the difference between the number of red candies in the blue jar and the number of blue candies in the red jar. That difference begins at zero and remains zero after every exchange. Randomness determines the number of red-for-blue pairs, but cannot change the difference.
Notice that we didn’t actually need 100 candies in each jar. The jars do not even need to contain the same number initially. We need only start with one color in each jar and transfer the same number of candies in both directions. The twenty is equally unimportant, except that it tells us how many exchanges we are considering.
We could still calculate the probability that, for instance, fifteen blue candies are returned to the red jar. That’s a perfectly legitimate statistical question. But if fifteen blue candies are returned, exactly fifteen red candies must remain in the blue jar. The probabilistic calculation adds nothing to that conclusion.
The interesting part of this puzzle is recognizing what we need to prove. The presence of a random selection does not mean that the question itself is probabilistic. In this case, induction establishes a relationship that must hold for every possible outcome, and we never have to calculate a single probability.