News for hackers. Stuff that matters.
Re:Stack Overflow: the Blind Leading the Blind by sah on Sunday August 31, 2008 @09:35PM (#291635)
Iterate through the list bitwise-XORing the numbers together into an accumulator. Because x ^ x = 0, and x ^ 0 = x, and ^ is commutative (x ^ y = y ^ x), the final value in the accumulator for a list like [x, y, y, x, z] is:

    x ^ y ^ y ^ x ^ z 
  = x ^ x ^ y ^ y ^ z
  = 0 ^ 0 ^ z
  = z

There are no comments on this comment yet.