Problem

Source:

Tags: number theory, combinatorics, Digits



Let us call the distance between the numbers $\overline{a_1a_2a_3a_4a_5}$ and $\overline{b_1b_2b_3b_4b_5}$ the maximum $i$ for which $a_i \ne b_i$. All five-digit numbers are written out one after another in some order. What is the minimum possible sum of distances between adjacent numbers?