human
Count triples with Bitwise AND equal to Zero | Function to find the number of triplets whose Bitwise AND is 0..
Stores the count of triplets having bitwise AND equal to 0.
Stores frequencies of all possible A [ i ] & A [ j ].
Traverse the array.
Update frequency of Bitwise AND of all array elements with a.
Traverse the array.
Iterate the map.
If bitwise AND of triplet is zero , increment cnt.
Return the number of triplets whose Bitwise AND is 0..
Driver Code.
Input Array.
Function Call"
Solution in Python:
assistant
#Here is code to count triples with Bitwise AND equal to Zero and the other steps required.
 def countTriplets ( A ) :
	cnt = 0 ;
	tuples = { } ;
	for a in A :
		for b in A :
			if ( a & b ) in tuples :
				tuples [ a & b ] += 1 ;
			else :
				tuples [ a & b ] = 1 ;
	for a in A :
		for t in tuples :
			if ( ( t & a ) == 0 ) :
				cnt += tuples [ t ] ;
	return cnt ;
if __name__ == " _ _ main _ _ " :
	A = [ 2 , 1 , 3 ] ;
	print ( countTriplets ( A ) ) ;