human
Sum of Bitwise XOR of each array element with all other array elements | Function to calculate for each array element , sum of its Bitwise XOR with all other array elements.
Declare an array of size 64 to store count of each bit.
Traversing the array.
Check if bit is present of not.
Increase the bit position.
Reduce the number to half.
Traverse the array.
Stores the bit position.
Stores the sum of Bitwise XOR.
Check if bit is present of not.
Reduce the number to its half.
Print the sum for A [ i ].
Given arr1 [ ].
Size of N.
Function Call"
How can the above be solved in Python?
assistant
#Here is code to sum of Bitwise XOR of each array element with all other array elements and the other steps required.
 def XOR_for_every_i ( A , N ) :
	frequency_of_bits = [ 0 ] * 32
	for i in range ( N ) :
		bit_position = 0
		M = A [ i ]
		while ( M ) :
			if ( M & 1 != 0 ) :
				frequency_of_bits [ bit_position ] += 1
			bit_position += 1
			M >>= 1
	for i in range ( N ) :
		M = A [ i ]
		value_at_that_bit = 1
		XOR_sum = 0
		for bit_position in range ( 32 ) :
			if ( M & 1 != 0 ) :
				XOR_sum += ( ( N - frequency_of_bits [ bit_position ] ) * value_at_that_bit )
			else :
				XOR_sum += ( ( frequency_of_bits [ bit_position ] ) * value_at_that_bit )
			M >>= 1
			value_at_that_bit <<= 1
		print ( XOR_sum , end = " ▁ " )
	return
A = [ 1 , 2 , 3 ]
N = len ( A )
XOR_for_every_i ( A , N )