I'm studying number theory and I meet this question:
(For those who knows Kaprekar's constant may skip 1st paragraph.)
Let $a$ be an integer with a 4-digit decimal expansion, with not all digits the same. Let $a'$ be the integer with a decimal expansion obtained by writing the digits of $a$ in descending order, and let $a''$ be the integer with a decimal expansion obtained by writing the digits of $a$ in ascending order. Define $T(a)=a'-a''.$
Show that the only integer with a four-digit decimal expansion with not all digits the same such that $T(a)=a $ is $a=6174$.
My attempt
Let $a'=\overline{a_4a_3a_2a_1}$, where $a_4\ge a_3\ge a_2\ge a_1$; $a''=\overline{a_1a_2a_3a_4}$.
$a=T(a)=a'-a''=1000(a_4-a_1)+100(a_3-a_2)+10(a_2-a_3)+(a_1-a_4)$
For $a_3=a_2$, $T(a)=\overline{(a_4-a_1-1)99(10+a_1-a_4)}$
As the largest digit of $a$ in this case is $9$, $a_4=a_3=9$,
so $T(a)=\overline{(8-a_1)99(a_1+1)}=8991-999a_1$. But no such pair of $(a_1,a)$ where $a=T(a)$ exists.
Therefore $a_3>a_2$.
$a=T(a)=\overline{(a_4-a_1)(a_3-a_2-1)(9+a_2-a_3)(10+a_1-a_4)}$
For each digit, as they can be rewritten into only $a_1,a_2,a_3$ or $a_4$,
we have:
$$a_4-a_1=a_1/a_2/a_3/a_4\implies10+a_1-a_4=10-a_1/10-a_2/10-a_3/10-a_4$$ $$a_3-a_2-1=a_2/a_1\implies 9+a_2-a_3=10-a_2/10-a_1$$
We now have $2\cdot4=8$ cases to deal with, which need to be solved by brute-force. But I don't like it.
Question
I'm stuck here. Originally I want to prove it as simply/algebraically as possible. Can someone give me some hint to proceed my proof? Or is there any more elegant way to prove it? Thank you.
P.S. I don't want diagram-like explanation, which I see in old posts in related topics.