Possible answer (if correct, credit goes to SurfaceDog):
There are actually only a small number of 4-digit combnations (much less than 8,999 actually).
1234
1235
1236
1237
etc.
Take that finite database. Now calculate the result to subracting the various anagrams with each one. This yields yet another finite database.
I would bet that every four-digit combination in that data base is unique. For example, I picked "1257", and subtracted it from "5721", yielding the number 4464. I circled the 6 and typed in "444".
Now I would bet you that, within the finite answer database, "444" appears only once - in the number 4464. Thus the program knew that 6 was the answer.
(Plus, remember that you aren't allowed to cirlce zero, by the rules of the game - this significantly reduces the size of the database).
Maybe, I don't know. Working with 4 digits, you would have 10 possibilities per position, with the exception of the first position, which can only have 9, because you can't use zero. That would mean 9,000 possibilities, with a like number of possible sums. Hmmm.....he's right, because all possible sums can be stored into a database, and they're each unique. All it takes is a little number crunching.