Find all possible pairs with given Bitwise OR and Bitwise XOR values | Function to find pairs with XOR equal to A and OR equal to B ; Iterate from 1 to B ; Check if ( i OR y ) is B ; Driver Code
def findPairs ( A , B ) : NEW_LINE INDENT for i in range ( 1 , B + 1 ) : NEW_LINE INDENT y = A ^ i NEW_LINE if ( y > 0 and ( i y ) == B ) : NEW_LINE INDENT print ( i , " ▁ " , y ) NEW_LINE DEDENT DEDENT DEDENT A = 8 NEW_LINE B = 10 NEW_LINE findPairs ( A , B ) NEW_LINE