Riddle: List of Numbers, Each Appears Twice …

One thought on “Riddle: List of Numbers, Each Appears Twice …”

  1. I love this kind of thing.

    If the numbers are a list of integers.
    Then, using the bitwise XOR (exclusive or) operator iteratively
    and a variable ‘store’

    do while{
    store = store ^ nextValue /* Where ‘^’ is the bitwise XOR operator
    } there are still numbers in the list

    All the similar values will XOR to zero and the odd man out will be left in ‘store.’

Leave a Reply to Perry Horwich Cancel reply