The distance of Hamming between two natural numbers is defined as the number of positions in these numbers that have different digits. For instance, the distance of Hamming of 70075 and 774 is 3:
7 0 0 7 5 | ||
7 0 7 7 4 | ⇒ | there are 3 differences |
Your task is to write a program that reads pairs of natural numbers and prints their Hamming distance and the sum of the digits which are in positions with different digits. In the instance, the sum is (7 + 0) + (0 + 7) + (5 + 4) = 23.
Your program must implement and use the procedure
that, given two natural numbers |a| and |b|, stores at the output parameter |dist| their Hamming distance, and stores at the output parameter |sum| the sum of the digits which are in positions with different digits.
Input
The input is a sequence of pairs of natural numbers.
Output
For each pair of the input, print its Hamming distance and the sum of the digits which are in positions with different digits in another line.
Observation
Remember to implement |calculates()| recursively. This procedure can not contain loops nor calls to other procedures.
Input
70075 774 774 70075 0 99999 100000 0 0 0 1234567 2345678
Output
3 23 3 23 5 45 1 1 0 0 7 63