*[Originally published at Doctroidal Dissertations.]*

Spoiler for New Scientist Enigma 1692:

Clever logic should enable you to find the nine-figure number that I have in mind. It consists of the digits 1 to 9 in some order, and in the number each digit is next to another that differs from it by one.

In just one case a digit has both neighbours differing from it by one. Furthermore, the solution is exactly divisible by more than three-quarters of the numbers 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11 and 12.

What is the nine-figure number?

The number can’t be divisible by 10, because it doesn’t end in 0. However, it has to be even if 10 of the first 12 integers are to be factors. So it can’t be divisible by 5 either. Having ruled out 5 and 10, the remaining numbers 1, 2, 3, 4, 6, 7, 8, 9, 11, and 12 must be factors.

If 11 is a factor then the sum of the digits in the odd places (call this *so*) minus the sum of the digits in the even places (call this *se*) must be a multiple of 11. In fact, since *so*+*se*=45, *so* and *se* must have opposite parity so must differ by 11. Therefore *so* = 28 and *se* = 17.

1 and 2 can’t both be in even places (or odd); neither can 8 and 9. So, looking at sets of four digits that sum to 17 and contain exactly one of 1 and 2 and exactly one of 8 and 9, there are only three possible even place / odd place divisions: 1349/25678, 1358/24679, or 2348/15679. But the first of these can be ruled out because 7 has to be next to 6 or 8, and likewise the last because 3 must be next to 2 or 4.

So the split must be 1358/24679. 9 must be an odd-place digit; 8 must be next to 9; and since 7 cannot be next to 6 it must be next to 8. Therefore 8 is the one digit for which both neighbors differ from it by one.

For divisibility by 4, and noting that the last two digits must differ by 1, that 1 and 2 must be adjacent, and that 7 cannot be next to 6, the last two digits must be 12 or 56. Then for divisibility by 8 the last 3 digits must be 312, 512, 712, 912, 256, 456, or 856. Of these 312, 512, and 856 are not possible with the odd-even place split required. 456 is ruled out because 5 differs from both 4 and 6 by one. So our number ends with 712, 912, or 256.

If 712: We have to end with 98712. The two preceding digits, and the two before them, can be 43 or 65, but 6543 isn’t allowed, so the only candidate is 436598712.

If 912: Similarly there is only one candidate, 436578912.

If 256: The preceding digit is 1. Then the first five digits must be the group 789 or 987, and 43 or 34. The four candidates are 437891256, 439871256, 789341256, and 987341256.

Of these six candidates only 436578912 is divisible by 7. Divisibility by 1, 2, 3, 4, 6, 8, 9, 11, and 12 has been guaranteed by our procedure, so this is the solution.