human
Count of pairs in Array such that bitwise AND of XOR of pair and X is 0 | Function to find the number of pairs that satisfy the given criteria i . e . , i < j and ( arr [ i ] ^ arr [ j ] ) & X is 0.
Stores the resultant count of pairs.
Initialize the dictionary M.
Populate the map.
Count number of pairs for every element in map using mathematical concept of combination.
As nC2 = n * ( n - 1 ) / 2.
Return the resultant count.
Driver Code"
How can the above be solved in Python?
 Can you provide a code to count of pairs in Array such that bitwise AND of XOR of pair and X is 0 and the other steps required?
assistant
#Here is code to count of pairs in Array such that bitwise AND of XOR of pair and X is 0 and the other steps required.
 def countOfPairs ( arr , N , X ) :
	count = 0
	M = dict ( )
	for i in range ( 0 , N ) :
		k = arr [ i ] & X
		if k in M :
			M [ k ] += 1
		else :
			M [ k ] = 1
	for m in M . keys ( ) :
		p = M [ m ]
		count += p * ( p - 1 ) // 2
	return count
if __name__ == ' _ _ main _ _ ' :
	arr = [ 3 , 2 , 5 , 4 , 6 , 7 ]
	X = 6
	N = len ( arr )
	print ( countOfPairs ( arr , N , X ) )