# Palindrome from the first 20 numbers

Can you concatenate the numbers from 1 to 20 in some order, such that the resulting 31-digit number is a palindrome?

Bonus: if there are multiple such palindromes then what is the smallest one?

Sure:

20 19 8 17 6 15 3 14 1 12 11 4 13 5 16 7 18 9 10 2

How I arrived at this solution:

All digits appear twice, except 1, which appears 12 times and 2 which appears three times. That means that the 2 with the only odd-numbered occurrence must go in the middle. One way to do so is:

... 12 1 ...

We can then place the other 2's at either end:
20 1? ... 12 1 ... 10 2

(The digit at the question mark is not yet known, but at least one of the ones must be part of one of the 'teens.) We can fill in the dots by noticing that we can make palindromic pairs like 3 14 / 4 13:

20 1? 8 17 6 15 3 14 12 1 4 13 5 16 7 18 10 2

The question mark is a nine:

20 19 8 17 6 15 3 14 12 1 4 13 5 16 7 18 9 10 2

Done! Let's cross-check: Ah, I've missed the 11. Fortunately, we can put it where the 1 is and move the 1 to its respective palindromic place:

20 19 8 17 6 15 3 14 1 12 11 4 13 5 16 7 18 9 10 2

• Nice work! I've added a bonus question is you are interested. Mar 21, 2022 at 0:44

EDIT: Found a smaller number, and rewrote the reasoning for it.

Since other people have already found palindromes, I attempted to make the smallest one:

1 10 2 3 14 5 16 7 18 9 12 19 8 17 6 15 4 13 20 11

This is my full process (including trial and error):

To make the smallest number, the numbers near the start of the list would need to be smaller, as the the later numbers have less of an effect on the overall number. 1 is the smallest lone number, but having a 10 is the smallest two-digit number it could begin with.

Since it's a palindrome, the other side would end with 01. As 20 is the only other number that contains a zero, the end would have to be 20 1, which makes the start 10 2.

As @MOehm said the middle number has to be a 2. Since 12 is the only remaining number with a 2, the middle three would be 12 1. As 1 has already been used, the 1 on the right has to be the start of one of the teen numbers.

But then there's 11, which can't fit anywhere, as for that to be reflected the 1 needs to be used. So, restart.

The second smallest two-digit number is 11. But there are only two numbers which end in 1, the other being 1, so the other end couldn't be reflected as 11. However, if the end was 11, it could start with 1 and then have a teen number following. The smallest number beginning with a 1 is 10. So, the start is 1 10. The only other number that ends with a zero is 20, which makes the end 20 11. The start would then have to be 1 10 2, as 2 is the only other number remaining that starts with 2.

As mentioned before, the middle has to be 2. 12 is the only number with 2 that remains, so the middle would 12 and then a teen number, as 1 has already been used.

From that, the remaining number combinations (e.g. 9 19) are arranged in ascending order so the higher numbers are smaller. So, the start would be 1 10 2 3, and the combination would continue ascending to the middle before descending in the last half of the numbers due to the reflection of number combinations, resulting in the answer.

• Well done! I believe this is the smallest palindrome possible. Mar 23, 2022 at 0:46

Noticing how M Oehm's solution can be manipulated, I have turned it into something else that could have been found with an entirely different approach.

Characteristic representation:

9 | 8 7 | 6 5 | 4 3 | 2 1 | 0 2 0 | 1 2 | 3 4 | 5 6 | 7 8 | 9

Ordinarily:

9187165143121102011213415617819

As a list:

9 18 7 16 5 14 3 12 1 10 20 11 2 13 4 15 6 17 8 19