Wally has a very unusual combination lock number. It has five digits, all different, and is divisible by 111 . If he removes the middle digit and replaces it at the end, the result is a larger number that is still divisible by 111. If he removes the digit that is now in the middle and replaces it at the end, the result is a still larger number that is still divisible by 111. What is Wally's combination lock number? Explain your answer!
The solution is 74259 . The numbers 74259, 74592, and 74925 are all divisible by 111 . Denote the original number by $\overline{a b c d e}$ (the line prevents confusion with $a \cdot b \cdot c \cdot d \cdot e$ ). Then we have

$$
\begin{aligned}
& 111 \mid \overline{a b c d e} \\
& 111 \mid \overline{a b d e c}
\end{aligned}
$$

Subtracting,

$$
\begin{gathered}
111 \mid \overline{a b d e c}-\overline{a b c d e} \\
111 \mid \overline{d e c}-\overline{c d e}
\end{gathered}
$$

Since the number $\overline{d e c}-\overline{c d e}=90 d+9 e-99 c$ is divisible by 9 we get $33|\overline{d e c}-\overline{c d e} .333| \overline{d e c}-\overline{c d e}$. Since it is given that $\overline{a b d e c}>\overline{a b c d e}, \overline{c d e} \leq \overline{d e c}-333$.

However, we could have done the above logic with $d, e, c$ instead of $c, d, e$ and gotten $\overline{d e c} \leq \overline{e c d}-333$. Consequently $\overline{c d e} \leq \overline{e c d}-666$. Since obviously $\overline{e c d} \leq 999, \overline{c d e}$ is one of the multiples of 37 up to 333:

$$
000037074111148185222259296333
$$

We can immediately eliminate $000,111,222$, and 333 , since we know that the digits are all different. We can also eliminate 074, 185, and 296, since $\overline{e c d}>\overline{d e c}$. The three remaining choices are all of the form $111 \cdot k+37$. So

$$
\begin{aligned}
11 \mid \overline{a b c d e} & \\
& =\overline{a b 000}+\overline{c d e} \\
& =999 \cdot \overline{a b}+\overline{a b}+111 \cdot k+37 \\
11 \mid \overline{a b}+37 &
\end{aligned}
$$

whence $\overline{a b}=74$. This leaves only three possibilities for Wally's combination lock number: 74037, 74148, and 74259, of which only the last has all unlike digits.