Write a program which takes a very large number of 64-bit binary words and calculate the partity of word. The parity of the word is 1 if the number of 1 is in the word is odd; otherwise, it is 0.
Brute force approach:
def parity(x): total = 0 while x: total ^= x & 1 x >>= 1 return total
This solution runs in O(n) time, where n is the size of the word x.