Viewer said:
Cool. Worked for me. And tomorrow, after a nice sleep, and while bored with work, I'll figure out how it works.
Two factoids from the "fun with nines" day in grade school math:
The sum of the digits of any number divisible by nine is itself divisible by nine.
Also, when you subtract (from a minuend) a subtrahend which is a permutation of the minuend, the difference is divisible by nine*.
Accordingly, when you've finished the subtraction in the puzzle, you have a number divisible by nine and whose sum of the digits is divisible by nine. What the puzzle does is add up the digits you entered and answers with the missing digit: the number needed to get to the next higher multiple of nine (which is why zeros are disallowed; if the sum of the digits received is already a mutiple of nine, fido wouldn't know if you held back a zero or nine).
*Quicky proof:
Let abcd represent any (four digit in this case) number.
abcd = a(1000) + b(100) + c(10) + d
= a(999 + 1) + b(99+1) c(9+1) + d
= a(999) + a + b(99) + b + c(9) + c + d
= a(999) + b(99) + c(9) + a+b+c+d
Any permutation of abcd can also be expressed the same way with the same "remainder" of a+b+c+d.
When you subtract a permutation of abcd from abcd, the "a+b+c+d" remainder gets canceled, leaving a difference always evenly divisible by nine (i.e., 999 times something plus 99 times something plus 9 times something).