There are two ways to solve this, the standard way and the way requiring you to have some small understanding of number theory. First the standard way. Let's rewrite it as an addition problem first:
119? + BDCA ------ ABCD
The first equation derives from the ones digit: ? + A = D mod 10. But the tens digit shows that 9 + C = C, so there MUST have been a carry in the ones digit, and we know that there will be a carry in the hundreds digit, regardless of what C is (If C = 0, 1 (carry) + 9 + 0 = 10, and if C = 9, 1 (carry) + 9 + 9 = 19, so that's why there's a carry of 1 coming to Mr. Hundreds digit). So really the ones equation (which we'll call equation a) reads:
The hundreds digits reveal a second equation, 2 + D = B mod 10 (remember we had the carry coming from Mr. Tens). We don't know if a carry is involved from the hundreds to the thousands, but let's assume there is. This means two equations are generated (we name these assumptions b-ass and c-ass for 'assumption'):
Now let's see if this is possible. Equation b-ass tells us that D must be either 8 or 9 (If it weren't, the left side of equation b-ass would never be bigger than 10, and we know the right side of b-ass is at least 10), but we know D can't be 9 because of equation a. Two single digits can't add to 19. So D must be 8, which means from equation a that ? and A must be both 9. We're done, you say, since we found out what '?' was, right? Well, let's just see about that. From equation c-ass we then know that B is 7, But then b-ass reads: 2 + 8 = 7 + 10, which is wrong. So our assumptions b-ass and c-ass were wrong. Then there is no carry from Mr. Hundreds to Mr. Thousands after all and those equations become:
Now, let's replace the variables D and A in a with their equivalences from b and c. So a rewritten becomes:
? = 7.
The second way involves the following understanding:
Using d, we see that
(119? mod 9) = ((1 + 1 + 9 + ?) mod 9).
We also see from f that
((ABCD mod 9) - (BDCA mod 9)) mod 9) = (119? mod 9).
But from d again we know that
(ABCD mod 9) = ((A + B + C + D) mod 9),
(BDCA mod 9) = ((B + D + C + A) mod 9).
Since addition is commutative,
((A + B + C + D) mod 9) = ((B + D + C + A) mod 9)
(ABCD mod 9) = (BDCA mod 9)
((ABCD mod 9) - (BDCA mod 9)) mod 9) = (0 mod 9) = 0
0 = (119? mod 9) = ((1 + 1 + 9 + ?) mod 9).
(11 + ?) mod 9 = 0.
? = 7.
Epilogue from Alex Berg:
This works in lots of problems, but one has to be careful because 9 is congruent to 0 modulo 9 so you would not know which to pick in case you had a choice.