A complete number is a $9$ digit number that contains each of the digits $1$ to $9$ exactly once. The difference number of a number $N$ is the number you get by taking the differences of consecutive digits in $N$ and then stringing these digits together. For instance, the difference number of $25143$ is equal to $3431$. The complete number $124356879$ has the additional property that its difference number, $12121212$, consists of digits alternating between $1$ and $2$. Determine all $a$ with $3 \le a \le 9$ for which there exists a complete number $N$ with the additional property that the digits of its difference number alternate between $1 $ and $a$.
Problem
Source: Dutch NMO 2019 p1
Tags: number theory, Digits
21.01.2020 15:28
$\textbf{Case 1}$: $3|a\Longleftrightarrow a\in\{3,6,9\}$. In this case, a complete number cannot have the additional property. Proof: a complete number contains exactly $3$ digits $n_i$ with the property $n_i\equiv k\pmod3$, for each $k\in\{0,1,2\}$. If $3|a$, then $n_2\equiv n_3\pmod3; n_4\equiv n_5\pmod3; n_6\equiv n_7\pmod3; n_8\equiv n_9\pmod3$. Hence, exist $4$ pairs of digits which can take at most $3$ distinct values modulo $3$. Results: exists $4$ digits with the property $n_i\equiv n_j\equiv n_k\equiv n_m\pmod3$, contradiction. $\textbf{Case 2}$: $3\nmid a$ and $a$ is an odd number. A complete number $N=\overline{n_1n_2\dots n_9}$ contains $5$ odd and $4$ even digits. For $a$ odd number, a complete number with the additional property contains the digits in the order $\overline{OEOEOEOEO}$ (O=odd; E=even). For $a=5$ exist solutions, for example: $N_5=549832761$. For $a=7$: the even digits are $n_2,n_4,n_6,n_8$. Obviously, $\{n_2,n_4,n_6,n_8\}=\{2,4,6,8\}\Longrightarrow |n_i-n_j|\le6, \forall i,j\in\{2,4,6,8\}, i\ne j$, with equality for $\{n_i,n_j\}=\{2,8\}$ The difference between two consecutive even digits (considering their positions in the number $N$) can be $\pm1\pm7$ (all possible combinations of signs), hence $|n_4-n_2|,|n_6-n_4|,|n_8-n_6|\in\{6,8\}\Longrightarrow |n_4-n_2|=|n_6-n_4|=|n_8-n_6|=6$. Results $\{n_2,n_4,n_6,n_8\}\subset\{2,8\}$, contradiction. $\textbf{Case 3}$: $3\nmid a$ and $a$ is an even number. For $a$ even number, a complete number with the additional property contains the digits in the order $\overline{OEEOOEEOO}$. For $a=4$ exist solutions, for example: $N_4=126734895$. For $a=8$: the even digits are $n_2,n_3,n_6,n_7$. Obviously, $\{n_2,n_3,n_6,n_7\}=\{2,4,6,8\}\Longrightarrow |n_i-n_j|\le6, \forall i,j\in\{2,3,6,7\}, i\ne j$. In the complete number with the additional property: $|n_3-n_2|=|n_7-n_6|=a=8>6$, contradiction. Final answer: A complete number $N$ can have the additional property that the digits of its difference number alternate between $1 $ and $a$ for: $a\in\{4,5\}$.