XOR Lost Number

Problem Statement

Chefina has 2 numbers A and B. She created another number C which is the bitwise XOR of A and B. Here, ^ denotes the bitwise XOR operation. Chefina somehow lost track of A and now only has B and C. Now she needs your help to find the lost number A.

Input Format:

  • The first line contains an integer T, the number of test cases (1 ≤ T ≤ 100).
  • Each test case contains two space-separated integers B and C (0 ≤ B, C < 231).

Output Format:

  • For each test case, print the number A on a new line.

Constraints:

  • 1 ≤ T ≤ 100
  • 0 ≤ B, C < 231
Sample Input
Sample Output

Explanation:

  • In the first test case, B = 2 and C = 3. A = B ^ C (A = 2 ^ 3) = 1.
  • In the second test case, B = 0 and C = 0. A = B ^ C (A = 0 ^ 0) = 0.

Solution

file_type_python xor_lost_number.py
for _ in range(int(input())):
    n, m = map(int, input().split())
    print(n ^ m)

Comments

Load Comments