The sets {a_{1}, a_{2}, ... , a_{999}} and {b_{1}, b_{2}, ... , b_{999}} together contain all the integers from 1 to 1998. For each i, |a_{i} - b_{i}| = 1 or 6. For example, we might have a_{1} = 18, a_{2} = 1, b_{1} = 17, b_{2} = 7. Show that ∑_{1}^{999} |a_{i} - b_{i}| = 9 mod 10.

**Solution**

If |a_{i} - b_{i}| = 6, then a_{i} and b_{i} have the same parity, so the set of such a_{i} and b_{i} contains an even number of odd numbers. But if |a_{i} - b_{i}| = 1, then a_{i} and b_{i} have opposite parity, so each such pair includes just one odd number. Hence if the number of such pairs is even, then the set of all such a_{i} and b_{i} also has an even number of odd numbers. But the total number of a_{i} and b_{i} which are odd is 999 which is odd. Hence the number of pairs with |a_{i} - b_{i}| = 1 must be odd, and hence the number of pairs with |a_{i} - b_{i}| = 6 must be even. Suppose it is 2k. Then ∑ |a_{i} - b_{i}| = (999 - 2k) 1 + 2k 6 = 999 + 10k = 9 mod 10.

© John Scholes

jscholes@kalva.demon.co.uk

11 May 2002