human
Find number of pairs in an array such that their XOR is 0 | Function to calculate the answer.
Finding the maximum of the array.
Creating frequency array With initial value 0.
Traversing through the array.
Counting frequency.
Traversing through the frequency array.
Calculating answer.
Driver Code.
Function calling"
How can the above be solved in Python?
 ... Give me a code to find number of pairs in an array such that their XOR is 0 and the other steps required?
assistant
#Here is code to find number of pairs in an array such that their XOR is 0 and the other steps required.
 def calculate ( a ) :
	maximum = max ( a )
	frequency = [ 0 for x in range ( maximum + 1 ) ]
	for i in a :
		frequency [ i ] += 1
	answer = 0
	for i in frequency :
		answer = answer + i * ( i - 1 ) // 2
	return answer
a = [ 1 , 2 , 1 , 2 , 4 ]
print ( calculate ( a ) )