Check if binary representation of a given number and its complement are anagram | An efficient Python3 program to check if binary representations of a number and it 's complement are anagram. ; Returns true if binary representations of a and b are anagram . ; _popcnt64 ( a ) gives number of 1 's present  in binary representation of a. If number  of 1s is half of total bits, return true. ; Driver Code
ULL_SIZE = 64 NEW_LINE def bit_anagram_check ( a ) : NEW_LINE INDENT return ( bin ( a ) . count ( "1" ) == ( ULL_SIZE >> 1 ) ) NEW_LINE DEDENT a = 4294967295 NEW_LINE print ( int ( bit_anagram_check ( a ) ) ) NEW_LINE