## Parallel Weighings Solution

I recently posted the following coin weighing puzzle invented by Konstantin Knop:

We have

Nindistinguishable coins. One of them is fake and it is not known whether it is heavier or lighter than all the genuine coins, which weigh the same. There are two balance scales that can be used in parallel. Each weighing lasts one minute. What is the largest number of coinsNfor which it is possible to find the fake coin in five minutes?

The author’s solution in Russian is available at his blog. Also, two of my readers, David Reynolds and devjoe, solved it correctly.

Here I want to explain the solution for any number of required weighings.

It is easy to see that for *n* weighings the information theoretical bound is 5^{n}. Indeed, each weighing divides coins into five groups: four pans and the leftover pile. To distinguish between coins, there can’t be two coins in the same pile at every weighing.

Suppose we know the faking potential of every coin, that is, each coin is assigned a value: potentially light or potentially heavy. If a potentially light coin is ever determined to be fake, then it must be lighter than a real coin. The same story holds for potentially heavy coins. How many coins with known potential can we process in *n* weighings?

If all the coins are potentially light then we can find the fake coin out of 5^{n} coins in *n* weighings. What if there is a mixture of coins? Can we expect the same answer? How much more complicated could it be? Suppose we have five coins: two of them are potentially light and three are potentially heavy. Then on the first scale we compare one potentially light coin with the other such coin. On the other scale we compare one potentially heavy coin against another potentially heavy coin. The fake coin can be determined in one weighing.

The discussion above shows that there is a hope that any mixture of coins with different potential can be resolved. After each weighing, we want the number of coins that are not determined to be real to be reduced by a factor of 5. If one of the weighings on one scale is unbalanced, the potentially light coins on the lighter pan, plus the potentially heavy coins on the heavier pan would contain the fake coin. We do not want this number to be bigger than one-fifth of the total number of coins we are processing. So we divide coins in pairs with the same potential, and from each pair we put the coins on different pans of the same scale. So in one weighing we can divide the group into five equal groups. If there is an odd number of coins with the same potential, then the extra coin doesn’t go on the scales.

The only thing that we is left to check is what happens if the number of coins is small. Namely, we need to check what happens when the number of potentially light coins is odd and the number of potentially heavy coins is odd, and the total number of coins is not more than five. In this case the algorithm requires us to put aside the extra coin in each group, but the put-aside pile can’t have more than one coin.

After checking small cases, we see that we can’t resolve the problem in one weighing when there are 2 coins of different potential, or when the 4 coins are distributed as 1 and 3.

On the other hand, if we have extra coins that are known to be real, then the above cases can be resolved. Hence, any number of coins with known potential greater than four can be resolved in ⌈log_{5}*n*⌉ weighings.

Now let’s go back to the original problem in which we do not know the coins’ potential at the start. After a weighing, if both scales balance, then all the coins on the scale are real and the fake coin is in the leftover pile and we do not know its potential. If a scale doesn’t balance then the fake coin is in one of its two pans: the lighter pan has coins that are potentially light and the heavier pan has coins that are potentially heavy.

Let’s add an additional assumption to the original problem. Suppose we have an unlimited supply of coins that we know to be real. Let *u*(*n*) be the maximum number of coins we can process in *n* weighings if we do not know their potential.

What would be the first weighing? Both scales might be balanced, meaning that the fake coin is in the leftover pile of coins with unknown potential. So we have to leave out not more than *u*(*n*−1) coins. On the other hand, exactly one scale might be unbalanced. In this case, all the coins on this scale will get their potential known. The number of these coins can’t be more than 5^{n-1}. But this is an odd number, so we can use one extra real coin to make this number even, in order to put the same number of coins in each pan on this scale.

So *u*(*n*) = 2 · 5^{n-1} + *u*(*n*−1), and *u*(1) = 3. This gives the answer of (5^{n}+1)/2. Now we need to go back and remember that we got this bound using an additional assumption that we have an unlimited supply of real coins. Looking closer, we do not need our additional supply of real coins to be unlimited; we just need not more than two real coins. The good news is that we will have these extra real coins after the first weighing. The bad news is that for the first weighing we do not have extra real coins at all. So in the first weighing we should put unknown coins against unknown coins, not more than 5^{n-1} on each scale, and as the number on each scale must be even, the best we can do is put 5^{n-1}−1 coins on each scale.

Thus the answer is (5^{n}−3)/2 for *n* more than 1.

We can generalize this problem to any number of scales used in parallel. Suppose the number of scales is *k*. Suppose the number of weighings is more than 1, then the following problems can be solved in *n* weighings:

- If all the coins have known potential, then the maximum number of coins that can be resolved is (2
*k*+1)^{n}. - If we do not know the potential of any coin and there is an unlimited supply of real coins, the maximum number of coins that can be solved is defined by a recursion:
*u*(*n*) =*k*(2*k*+1)^{n-1}+*u*(*n*−1) and*u*(1)=*k*+ 1. So the answer is: ((2*k*+1)^{n}+1)/2. - If we do not know the potential of any coin and there is no extra real coins, then the answer is
*u*(*n*) −*k*= ((2*k*+1)^{n}+1)/2 −*k*.

The methods I described can be used to answer another common question in the same setting: Find the fake coin and say whether it is heavier or lighter. Let us denote by *U*(*n*) the number of coins that can be resolved in *n* weighings when there is an unlimited supply of extra real coins. Then the recurrence for *U*(*n*) is the same as the recurrence for *u*(*n*): *U*(*n*) = 2·5^{n-1} + *U*(*n*−1). The only difference is in the initial conditions: *U*(1) = *k*. This means that *U*(*n*) = ((2*k*+1)^{n}−1)/2. If we don’t have extra real coins then the answer is: *U*(*n*) = ((2*k*+1)^{n}−1)/2 − *k*.

When we don’t need to say whether the fake coin is heavier or lighter, we can add one extra coin to the mix: the coin that doesn’t participate in any weighing and is fake if the scales always balance.