It’s now been a year since I took over the puzzle column at New Scientist and turned it into the BrainTwisters column. By way of celebration, I thought I’d write up an interesting bit of maths behind one of the puzzles, which I made a note of at the time and have been meaning to share.
Here’s the puzzle, if you want to have a look:
Rectangulator
Given a standard calculator keyboard, press – in order, going either clockwise or anticlockwise – four digit keys that form the corners of a square or rectangle on the keypad. This will create a four-digit number, e.g. 7469.
If the first button you press is the 7 key, how many possible four-digit numbers can you create?
What about if your square or rectangle is allowed to have a height or width of zero?
Can you show that for any square or rectangle you choose, the resulting four-digit number will always be divisible by 11?
If you’d like to take some time to think about this, go away and do that now – then I’ll share the solution.
Solution
Here’s the solution we put in the magazine, which had to be kept fairly short:
From the 7, we can go round a rectangle, with width or height 1 or 2, in either direction. Eight numbers are possible: 7854, 7821, 7964, 7931, 7458, 7469, 7128 and 7139. If you allow zero width/height, you can also have 7777, 7887, 7997, 7447 and 7117.
For zero-height or width rectangles, the first two digits are the last two digits reversed. This will always be a multiple of 11, since it will be a sum of multiples of 110 and 1001, both multiples of 11. If we extend the rectangle, we move both numbers horizontally or vertically by the same distance. Instead of 7117, we could extend to the right and get 7128. This won’t affect whether it is a multiple of 11, as we are adding or taking away 11 per column we move. Likewise, extending a zero-height rectangle horizontally, we just add or subtract 33 per row we move.
Digging Deeper
The terse solution we gave hides a slightly more elegant algebraic version, which can be explained as follows.
From the button \( n \), moving right one or two will give \( n+1\) or \( n+2\), and moving down will subtract 3 – so the corners of a clockwise rectangle \(a \) wide and \( b \) tall would be \(n\), \(n+a\), \(n+a-3b\), \(n-3b\) (where a and b are 1 or 2). Going anticlockwise we’d get \( n\), \(n-3b\), \(n+a-3b\), \(n+a\). We can construct similar formulae for going up and left.
For the clockwise example above, using those values as the four digits, the number would be:
\[1000n + 100(n+a) + 10(n+a-3b) + (n-3b)\]
This can be rearranged to:
\[1111n + 110a – 33b\]
Since each of these terms must be divisible by 11, the whole sum must also be. This can also be checked for the anticlockwise version and for the ‘up and left’ variant – the result is always divisible by 11.
But that’s not a11
As part of the rigorous* process all puzzles go through before appearing in the column, I have a small team of testers who get to play with them first – including site pal and weekly-newsletter-botherer Colin Beveridge. Colin noticed an interesting pattern in the numbers which gives an alternative way to prove this will always give a multiple of 11.
Colin noticed that for (e.g.) 7821,
- 7000 is seven less than a multiple of 11
- 800 is eight more than a multiple of 11
- 20 is two less than a multiple of 11
- 1 is one more than a multiple of 11
Adding them up gives something that’s 0 more than a multiple of 11, since \( -7 + 8 – 2 + 1 = 0\).
It’s not a coincidence that for each of these multiples of a power of ten, the distance away from a multiple of 11 is the same as the digit at the start. To see why, we need to think about the nearest multiple of 11 to 1, 10, 100, 1000 etc. – and these are 11, 99, 1001, 9999, etc., which are one away (in alternating directions). So if we multiply these by a factor, the distance away will also increase by that same factor.
This means that if a number is \( x\) with an an odd number of zeroes on the end, it’s \( x\) less than a multiple of 11, and if a number is \( x\) with an even number of zeroes on the end it’s \( x \) more than a multiple of 11. If this isn’t a pattern you’d noticed before, isn’t it fun?
So in order for the whole number to be a multiple of 11, we just need the alternating sum of the four digits to be 0. Because of the way the rectangle is set up, the difference between the first and second number is always the same as the difference between the third and fourth, but with the opposite sign — so the alternating sum must be zero.
With a bit of practice, it’s possible to figure out how many elevens you have mentally: it’s always 100 times your starting number, plus or minus 10 times the number of columns moved (positive if you’ve moved right), plus the final number — so for 7821, it’s \( 7 \times 100 + 1 \times 10 + 1\), or 711. For 9713, it’s \( 9 \times 100 – 2 \times 10 + 3\), or 883. You can see this by considering the number two digits at a time: 7821 is \( 7800 + 21\), or \( 7700 + (100 + 10) + 11 \); 9713 is \( 9700 + 13 \), or \(9900 – (200 + 20) + 33\).
The puzzle column continues apace at newscientist.com (not free I’m afraid, but subscriptions are often available through institutional access or local library membership), and I’m sure we’ll come across more interesting maths in the process. Watch this space!