# Finding when the distances to three cities again have different digits

Very confused on this question. How would you solve it, and what would be the answer(s).

Recently I was driving down the freeway and spotted the following freeway sign with the distances to three upcoming cities:

• Ahmanson: 147 Miles

• Chandler: 265 Miles

• Schubert: 380 Miles

I thought the sign was unusual because the distances to the three cities featured all different digits. I realized that in 100 miles, the distances to the three cities would again have all different digits. But I wanted to know if that could happen sooner. In how many miles would I next see another freeway sign with all different digits for the distances to the three cities?

• Well, you could program a computer to look at what happens after 1 mile, then after 2 miles, and so on, until it finds one with all digits different. Oh, those "towns" are all names of theaters. – Gerry Myerson Mar 13 '14 at 11:53

Let $x$ be the number of miles since you passed that sign. To find the smallest value of $x > 0$ with the given property, we can exclude some cases, due to the initial digits $1,2,3$ of $A, C, S$.

• If $8 \leq x \leq 37$, the second digit of $A$ will be one of $1,2,3$.
• If $26 \leq x \leq 47$, the second digit of $C$ will be one of $1,2,3$ (and the first digit of $A$ is still a $1$).
• If $41 \leq x \leq 60$, the second digit of $S$ will be one of $2,3$.
• If $66 \leq x \leq 70$, the second digit of $S$ will be a $1$, which is then equal to the first digit of $C$.

This already excludes all numbers below $70$, except for $1, \dots, 7$ and $61, \dots, 65$. Excluding the remaining cases in a straightforward way is not so easy though, but we can do this in a somewhat structured way by looking at the last digits of $A,C,S$ and comparing them to the first digits of $A,C,S$.

• If $x \equiv 2 \pmod{10}$ and $x \leq 80$, the last digit of $C$ is the same as the first of $S$.
• If $x \equiv 3 \pmod{10}$ and $x \leq 65$, the last digit of $C$ is the same as the first of $C$.
• If $x \equiv 4 \pmod{10}$ and $x \leq 80$, the last digit of $A$ is the same as the first of $S$.
• If $x \equiv 5 \pmod{10}$ and $x \leq 65$, the last digit of $A$ is the same as the first of $C$.
• If $x \equiv 6 \pmod{10}$ and $x \leq 47$, the last digit of $A$ is the same as the first of $A$.
• If $x \equiv 7 \pmod{10}$ and $x \leq 80$, the last digit of $S$ is the same as the first of $S$.
• If $x \equiv 8 \pmod{10}$ and $x \leq 65$, the last digit of $S$ is the same as the first of $C$.
• If $x \equiv 9 \pmod{10}$ and $x \leq 47$, the last digit of $S$ is the same as the first of $A$.

This means that below $70$, we only have to check $1$ and $61$ by hand. $x = 1$ is not a solution, but $\boxed{x = 61}$ is a solution, and hence the smallest solution.

To find all solutions with $x < 100$, you could try continuing a similar approach. Since I'm too lazy for that, I'll just give you the other solutions using brute force:

$$x = (61), 78, 87, 91.$$