Let a $9$-digit number be balanced if it has all numerals $1$ to $9$. Let $S$ be the sequence of the numerals which is constructed by writing all balanced numbers in increasing order consecutively. Find the least possible value of $k$ such that any two subsequences of $S$ which has consecutive $k$ numerals are different from each other.
Problem
Source: 2023 Turkey MO 2nd Round P3
Tags: combinatorics
BarisKoyuncu
22.12.2023 21:44
The answer is $17$. Let's begin by showing that $k\geq 17$. The first $18$ elements of $S$ are $123456789123456798$. Also, the next balanced number after $234567891$ is $234567918$. Hence, $S$ also includes the sequence $234567891234567918$. See that both of these sequences of length $18$ include the subsequence of $2345678912345679$ of length $16$. Hence, $k$ cannot be $16$.
Let's move on to proving that there are no identical subsequences of length $17$. FTSOC, assume that the subsequences $X$ and $Y$ of length $17$ are identical. From this point on, let's call a balanced $9$-digit number a block. Both $X$ and $Y$ consist of either $2$ or $3$ blocks. Also, since $2\cdot 9>17>2\cdot 8$, we see that both $X$ and $Y$ include exactly one full block (i.e. they include a full $9$-digit balanced number that was used to create $S$)
WLOG, assume that the sequence $X$ looks like the following $$\begin{tabular}{|c|c|c|}
\hline
$b_1, \cdots, b_y$ & $a_1, a_2,\cdots ,a_9$ & $c_1, \cdots, c_x$ \\
\hline
\end{tabular}$$where $a_1,\cdots ,a_9$ is a full block and the other the are partial blocks. We have $x+y=8$. Either $x$ or $y$ could be $0$, which equates to $X$ consisting of two blocks instead of three. (Here, all of $b_1,\cdots, b_y, a_1,\cdots ,a_9, c_1,\cdots ,c_x$ are digits from $1$ to $9$. Clearly, $b_i$ s are different from one another, same for $a_i$ s and $c_i$ s) Call these three blocks $B, A$ and $C$, respectively. $X$ includes the whole block $A$ but only some digits from $B$ and $C$.
Similarly, assume that the sequence $Y$ looks like the following $$\begin{tabular}{|c|c|c|}
\hline
$d_1, \cdots, d_z$ & $e_1, e_2,\cdots ,e_9$ & $f_1, \cdots, f_t$ \\
\hline
\end{tabular}$$where $e_1,\cdots ,e_9$ is a full block and $z+t=8$.
Since $X$ and $Y$ are identical, we know that $b_1=d_1, b_2=d_2, \cdots ,c_x=f_t$.
If $y=z$, then we can see that $(a_1,\cdots, a_9)=(e_1, \cdots ,e_9)$ so these two blocks are the same. Also, both $X$ and $Y$ include $y$ digits before this block so they are the exact same subsequences of $S$, contradiction. Hence, $y\neq z$. WLOG, assume that $y>z$ and $8\geq y-z=j>0$.
Now, let's look at a crucial lemma.
Lemma: Given two consecutive blocks (balanced $9$-digit numbers) from $S$, $K:\boxed{p_1,\cdots ,p_9}$ and $L:\boxed{q_1,\cdots ,q_9}$ . If the last $i$ digits ($1\leq i\leq 8$) of these blocks are permutations of each other (so $\{p_{10-i}, p_{11-i},\cdots ,p_9\}=\{q_{10-i}, q_{11-i},\cdots ,q_9\})$), then the first $9-i$ digits are the same (so $p_1=q_1, p_2=q_2, \cdots, p_{9-i}=q_{9-i}$)
ProofTrivial for $i=8,9$. Assume that $1\leq i\leq 7$. Let $j$ be the smallest integer for which $p_j\neq q_j$. Notice that we are done if $j>8-i$. Assume that $p_j<q_j$. Since there are no other blocks between $K$ and $L$, we know that $K$ is the last block (largest one) starting with $p_1,p_2,\cdots ,p_j$ and $L$ is the first block (smallest one) starting with $q_1, q_2,\cdots, q_j$ so $p_{j+1}>p_{j+2}>\cdots >p_9$ and $q_{j+1}<q_{j+2}<\cdots <q_9$. Hence, the largest number of the set $S^*=\{p_j, p_{j+1},\cdots ,p_9\}$, say $\ell$, cannot be one of the last $i$ digits of $K$, so it is not one of the last $i$ digits of $L$. Yields, $q_j=\ell$. Similarly, $p_j$ must be the smallest element of $S^*$, which contradicts the fact that there are no other blocks between $K$ and $L$.
Credit: Thanks to @hakN for this short and elegant proof of the lemma.
Using this, we can easily verify that the last digits of any two consecutive blocks cannot be the same.
Since $(b_{z+1}, \cdots ,b_y, a_1,\cdots a_{9-j}, a_{10-j},\cdots, a_9)=(e_1,\cdots, e_j, e_{j+1}, \cdots, e_9, f_1,\cdots f_j)$, we have $\{e_1,\cdots, e_j\}=\{a_{10-j}, \cdots ,a_9\}=\{f_1, \cdots ,f_j\}$. Then, the first $j$ elements of blocks $E$ and $F$ are permutations of each other. Hence, the last $9-j$ elements of these blocks are permutations of each other. Then, by using our lemma, we can see that their first $j$ elements are the same. Finally, $b_y=e_j=f_j=a_9$, which means that the last digits of blocks $B$ and $A$ are the same, contradiction.