I am fairly new to python and I came upon this code to find a single element in a list
Here is the code:
def single_number(arr):
ones, twos = 0, 0
for x in arr:
ones, twos = (ones ^ x) & ~twos, (ones & x) | (twos & ~x)
assert twos == 0
return ones
arr1 = [5, 3, 4, 3, 5, 5, 3]
print(single_number(arr1))
I just can't seem to understand what the line is doing
ones, twos = (ones ^ x) & ~twos, (ones & x) | (twos & ~x)
assert twos==0