4 ms·
Here's an example in python: >>> import random, operator >>> nums = (range(5)*2) >>> random.shuffle(nums) >>> nums.pop() 1 >>> nums [0, 4, 0, 3,
by brianr 18y ago
Here's an example in python:
>>> import random, operator
>>> nums = (range(5)*2)
>>> random.shuffle(nums)
>>> nums.pop()
1
>>> nums
[0, 4, 0, 3, 2, 4, 3, 1, 2]
>>> reduce(operator.xor, nums)
1
- thorax 18y agoTo clarify for non-Pythoners/non-coders: If you assume "nums" already contains the list, most of his code above is setup. You only need these two lines of his code to get the answer: import operator answer = reduce(operator.xor, nums)