human
Count of pairs whose bitwise AND is a power of 2 | Function to check if x is power of 2.
Returns true if x is a power of 2.
Function to return the number of valid pairs.
Iterate for all possible pairs.
Bitwise and value of the pair is passed.
Return the final count.
.
Given array.
Function Call"
Solution in Python:
assistant
#Here is code to count of pairs whose bitwise AND is a power of 2 and the other steps required.
 def check ( x ) :
	return x and ( not ( x & ( x - 1 ) ) )
def count ( arr , n ) :
	cnt = 0
	for i in range ( n - 1 ) :
		for j in range ( i + 1 , n ) :
			if check ( arr [ i ] & arr [ j ] ) :
				cnt = cnt + 1
	return cnt
/ * Driver Code * /
arr = [ 6 , 4 , 2 , 3 ]
n = len ( arr )
print ( count ( arr , n ) )