Decimal XOR
InterviewTime limit1sMemory limit1024 MB
Given two integers up to 999,999, compute their digit-wise DEXOR, where each digit pair gives 0 if both digits are at most 2 or both are at least 7, otherwise 9.
- Level
Easy2 of 10
- Topics
- Implementation, Math
- Solved
- No attempts yet
Problem
The binary operation XOR takes two binary digits as input and outputs a binary digit. If both input digits are 0 (or both are 1), the output is 0. Otherwise the output is 1. Equivalently, if both input values are low (or both are high), the output is 0. Otherwise the output is 1.
Decimal numbers have several digits, and each digit can be one of 10 values (0-9). We define the operation DEXOR (XOR of two decimal numbers) as follows. We DEXOR two decimal digits at a time. The two digits at the 1st position are DEXOR'ed, the two digits at the 10th position are DEXOR'ed, the two digits at the 100th position are DEXOR'ed, and so on. When DEXOR'ing two decimal digits, the result digit is 0 if both digits are too small () or both digits are too large (). Otherwise the result digit is 9.
Given two decimal numbers, compute their DEXOR.
Input
There are two input lines. Each line has a decimal number between 0 and 999,999 (inclusive). No input number has extra leading zeroes.
Output
Print the DEXOR of the two decimal numbers. If one number has fewer digits, treat it as having zeros on the left so that both numbers have the same number of digits. The result has as many digits as the larger number.
Hint
For example, 29 is treated as 00029 when it is DEXOR'ed with 18908, so that both numbers have five digits and can be DEXOR'ed digit by digit.