Problem 8 · Subtracting the reversed number
$\overline{abcd} - \overline{dcba} = 999(a-d) + 90(b-c)$.
Integer answer, at most 4 digitsWhat is the largest difference we can get by subtracting from a four-digit number with all distinct digits the number obtained by reversing its digits, which must also be a four-digit number?
Copa Cangur · SCM
Hard
Closed answer
Reasoned solution
Key idea: write the difference in terms of the digits and optimise each term separately.
$$\overline{abcd} - \overline{dcba} = 999(a - d) + 90(b - c).$$
The dominant term wants $a - d$ as large as possible. Since the reversed number must have four digits, $d \ne 0$: best is $a = 9$, $d = 1$. Then maximise $b - c$ with digits different from $9$ and $1$: $b = 8$, $c = 0$.
$$999 \cdot 8 + 90 \cdot 8 = 7992 + 720 = 8712. \qquad (9801 - 1089 = 8712.)$$
Answer: 8712