human
Count all pairs with given XOR | Returns count of pairs in arr [ 0. . n - 1 ] with XOR value equals to x ..
create empty map that stores counts of individual elements of array ..
If there exist an element in map m with XOR equals to x ^ arr [ i ] , that means there exist an element such that the XOR of element with arr [ i ] is equal to x , then increment count ..
Increment count of current element.
return total count of pairs with XOR equal to x.
Driver Code"
How can the above be solved in Python?
 ... Write me a code to count all pairs with given XOR and the other steps required?
assistant
#Here is code to count all pairs with given XOR and the other steps required.
 def xorPairCount ( arr , n , x ) :
	m = dict ( )
	for i in range ( n ) :
		curr_xor = x ^ arr [ i ]
		if ( curr_xor in m . keys ( ) ) :
			result += m [ curr_xor ]
		if arr [ i ] in m . keys ( ) :
			m [ arr [ i ] ] += 1
		else :
			m [ arr [ i ] ] = 1
	return result
arr = [ 2 , 5 , 2 ]
n = len ( arr )
x = 0
print ( " Count ▁ of ▁ pairs ▁ with ▁ given ▁ XOR ▁ = ▁ " , xorPairCount ( arr , n , x ) )