# Enigma 1719

Spoiler for New Scientist Enigma 1719:

I have before me a pile of nine counters numbered one to nine. I take two counters from the pile and write down the average of the numbers made by arranging them in two ways, that is in their original order and reverse order.

I then take a third counter from the pile and calculate the average of the numbers made by arranging the three counters in all possible orders. I repeat this until I have used all nine counters, ending up with eight averages. All but one of these averages are whole numbers, and the one that isn’t can be accurately written to one decimal place.

How many counters were used to generate the average that isn’t a whole number?

This is one of those problems where I started off not even sure I could think of an approach to it. But it turns out to be pretty straightforward.

If there are two counters numbered a and b then one arrangement of them gives the two digit number ab, that is, 10a+b, and the other number is 10b+a. The sum is 10(a+b)+(a+b) = 11(a+b) and the average is 11(a+b)/2.

With three counters the six numbers you get are 100a+10b+c,  100a+10c+b, 100b+10a+c, 100b+10c+a, 100c+10a+b, and 100c+10b+a. The sum is 222(a+b+c) and the average is 222(a+b+c)/6. The number of arrangements is 3! = 6, the number of times (for instance) a appears in the hundreds place is 2! = 2 each of which contributes 100a to the sum, and so forth.

Likewise with four counters the average is (3!/4!)1111(a+b+c+d) and in general, for n counters, the average is ((n-1)!/n!)(10n-1)/9 times the sum of the numbers on the counters. That expression more simply is (10n-1)/(9n) times the sum. (The quantity (10n-1)/9 is just the n-digit number all of whose digits are 1.) Let’s compute these:

n (10n-1)/(9n)
2 5 1/2
3 37
4 277 3/4
5 2222 1/5
6 18518 1/2
7 158730 1/7
8 1388888 7/8
9 12345679

The 3- and 9-counter averages are automatically whole numbers. For the others to be whole numbers the n-counter sums must be divisible by n, except for n=6 where the sum need only be divisible by 2.

Working backwards, let’s start with all nine counters. The sum is 45, and the average is 45(12345679) = 555555555.

Now take away one counter. To get a whole number average the sum must be a multiple of 8, and the only possibility is 40. So the counter taken away is 5 and the average is 55555555.

Now take away another counter. To get a whole number average the sum must be a multiple of 7, and the only possibility is 35. But we can’t get to 35 from 40; we’ve already taken away the 5 counter.

So either the 7-counter average or the 8-counter one must not be  a whole number. If the 7-counter average isn’t a whole number then it’s a repeating decimal, so it must be the 8-counter average that isn’t a whole number.

That answers the problem, but let’s check that we really can replicate the whole scenario. Again working backwards, to get an 8-counter average with one decimal place the sum must be a multiple of 4 (but not 8): either 44 or 36, by taking away 1 or 9 respectively. Let’s take away 1 to get a sum of 44, and the average is 61111110.5. Next we need to get to 35 or 42, multiples of 7; let’s take away 2 to get to 42. From there we can take away 4 to get to 38, a multiple of 2; take away 8 to get to 30, a multiple of 5; take away 6 to get to 24, a multiple of 4; take away 3 to get 21, which doesn’t need to be a multiple of anything; take away 7 to get 14, a multiple of 2.

Or, running time forward again:

Start with 5 and 9. Average of 59 and 95 is 77.

Add 7. Sum is 21, average of 579, 597, 759, 795, 957, and 975 is 777.

Add 3. Sum is 24, average is 6666.

Add 6. Sum is 30, average is 66666.

Add 8. Sum is 38, average is 703703.

Add 4. Sum is 42, average is 6666666.

Add 2. Sum is 44, average is 61111110.5.

Add 1. Sum is 45, average is 555555555.

This isn’t the only scenario that works (we could start with any two of 3, 5, 7, and 9, then add the other two in either order, for instance) but as shown above, it has to be the 8-counter average that isn’t a whole number.