[ Tasks with constraints $]$

The distance between numbers $a_{1}^{-} a_{2}^{2} a_{3}^{-} a_{4}^{-} a_{5}^{-}$ and $b_{1}^{-} b_{2}^{-} b_{3}^{-} b_{4}^{-} b_{5}^{-}$ is defined as the maximum $i$ for which $a_{i} \neq b_{i}$. All five-digit numbers are written one after another in some order. What is the minimum possible sum of distances between adjacent numbers

#
Let $x_{1}, x_{2}, x_{3}, x_{4}, x_{5}$ denote the number of pairs of consecutive numbers with distances of $1, 2, 3, 4, 5$ respectively. Since there are only 10 last digits, they must change at least 9 times, so $x_{5} \geq 9$.

The number of pairs of the last two digits is 100, so similarly $x_{4}+x_{5} \geq 100-1=99$. We can derive three more inequalities in the same way:

$x_{3}+x_{4}+x_{5} \geq 999, x_{2}+x_{3}+x_{4}+x_{5} \geq 9999, x_{1}+x_{2}+x_{3}+x_{4}+x_{5}=89999$, where the number on the right in the last equality is the total number of five-digit numbers, reduced by 1. Adding all these inequalities, we get: $x_{1}+$ $2 x_{2}+3 x_{3}+4 x_{4}+5 x_{5} \geq 101105$

Notice that the left side of this inequality is precisely the sum of the distances between consecutive numbers.

Now let's prove that this estimate is exact. For each number $n=\overline{a_{1}} \overline{a_{2}} \overline{\overline{2}} \overline{a_{3}} \overline{a_{4}} \overline{a_{4}} \overline{a_{5}}$, consider the number $n^{\prime}=\overline{a_{5}} \overline{y_{4}} \overline{a_{4}} \overline{a_{3}} \overline{\overline{3}} \overline{a_{2}} \overline{a_{1}} \overline{1}$ (it may start with zeros, but it cannot end with a zero) and write the numbers $n^{\prime}$ in ascending order. In the corresponding order, write the original numbers $n$.

Notice that in this order, the first digit of the numbers $n^{\prime}$ (which is the last digit of $n$) changes 9 times, the first two digits change 99 times, and so on, since any first $k$ digits of the numbers $n^{\prime}$ also go in order in this sequence.

Thus, all the inequalities listed above turn into equalities.

## Answer

101105.