Magic in XOR

4

1 votes
Easy, Simple-math
Problem

This question is quite simple.

You will be given 2 numbers let's say 'A' and 'C' and you have to find a number 'B' such that A (+) B = C.

A (+) B = C can be read as A xor B = C.

You can read more about XOR operation here: link

See Sample test-case for more understanding.

Note: In all programming languages, you can XOR two numbers say X and Y by ‘^’ (shift-6) key.

Time Limit: 0.5
Memory Limit: 4048
Source Limit:
Explanation

Let's take B as 3:

     0101 (decimal 5)
XOR  0011 (decimal 3) 
  = 0110 (decimal 6)

As we can see that A = 5, C = 6.

So as per formula A (xor) B => C. Suppose B = 3, 5 (xor) 3 => 6 is obtained.

Hence, B = 3 satisfies formula A xor B = C.

Thus, output is 3 as B = 3.

Editor Image

?