Ultra-Fast Mathematician
Practice this coding question on Coding Gurukul.
Problem statement
A communications lab compares two binary sensor snapshots captured at the same positions. The diagnostic display should mark a position with 1 when the two snapshots disagree and 0 when they agree. It must preserve every position, including leading zeroes, because the result is a mask rather than a numeric total. You are implementing this position-by-position comparison. Your task Read two binary strings of equal length. At each index, output 1 if the corresponding characters differ and 0 if they are the same. Concatenate those output bits in the original order to form one string. This is a bitwise exclusive-or mask with no carries between positions. Important details Do not parse the strings as decimal numbers or drop leading zeroes. Identical snapshots produce an all-zero mask. The output length must equal the length of either input. Worked example For snapshots 0011 and 0101, positions one and four agree while the middle positions differ. The output mask is 0110.
Input format
Two lines, each containing a binary string of the same length.
Output format
Print the binary difference mask.
Constraints
1 <= string length <= 100; only 0 and 1.
Sample input
0011 0101
Sample output
0110
Sign in to run or submit a solution in C++, Java or Python.