# function for checking for binary representations # of two numbers anagram from collections import Counter def checkAnagram (num1, num2): # convert numbers to binary # and remove the first two characters # output string because bin function # & # 39 ; 0b & # 39; as a prefix in the output line bin1 = bin (num1) [ 2 :] bin2 = bin (num2) [ 2 :] # add zeros to the shorter string zeros = abs ( len (bin1) - len ( bin2)) if ( len (bin1)" len (bin2)): bin2 = zeros * ’0’ + bin2 else : bin1 = zeros * ’ 0’ + bin1 # into a dictionary dict1 = Counter (bin1) dict2 = Counter (bin2) # compare both dictionaries if dict1 = = dict2: print ( ’Yes’ ) else : print ( ’No’ ) # Driver program if __ name__ = = "__ main__" : num1 = 8 num2 = 4 checkAnagram (num1, num2) |