To keep it short, if we XOR( exclusive OR) all the numbers together, the result will be our answer.
For not getting too deep into the math proofs, we need to prove 4 properties
1. a^a=0 ( any number XORed with itself is 0)
2. a^0=a (any number XORed with 0 is equal to himself)
3. (a^b)^c=a^(b^c) (the associative rule)
4. a^b=b^a (the commutative rule)
All those rules are really very obvious to prove.
So, the only thing we need to do is to input all the numbers, XOR them and output the result.
For not getting too deep into the math proofs, we need to prove 4 properties
1. a^a=0 ( any number XORed with itself is 0)
2. a^0=a (any number XORed with 0 is equal to himself)
3. (a^b)^c=a^(b^c) (the associative rule)
4. a^b=b^a (the commutative rule)
All those rules are really very obvious to prove.
So, the only thing we need to do is to input all the numbers, XOR them and output the result.
No comments:
Post a Comment