# Almost Constant Digits

How many 10-digit numbers containing only 1s, 2s and 3s can you write?

How many ten-digit numbers are there which contain only the digits $1$, $2$ or $3$, and in which any pair of adjacent digits differs by $1$?

If you liked this problem, here is an NRICH task which challenges you to use similar mathematical ideas.

The digits $1$ and $3$ will always be followed by the digit $2$. The digit $2$ can be followed by either $1$ or $3$. Hence the digit $2$ appears exactly five times in a ten digit number, in alternate positions.

If the first digit is $2$, then in each even position we have two choices, $1$ or $3$. This gives $2\times 2\times 2\times 2\times 2 = 32$ possibilities. Otherwise, the second digit is $2$ and in each odd position we have two choices. So again there are $32$ possibilities, making a total of $64$