## Determining a Hidden Digit

Source

I got this problem from Rustan Leino, who got this problem from Olean Brown, who had pointed me to the following web page that claims to read your mind.

I solved it and wrote up my solution.

Problem

Think of a positive integer; call it $X$. Shuffle the decimal digits of $X;$ call the resulting number $Y.$ Subtract the smaller of $X$ and $Y$ from the larger; call the difference $D.$ $D$ has the following property: Any non-zero decimal digit of $D$ can be determined from the remaining digits. That is, if you ask someone to hide any one of the non-zero digits in the decimal representation of $D,$ then you can try to impress the other person by figuring out the hidden digit from the remaining digits. How can you do this? Why does it work?

Solution