Check if a pair of integers from two ranges exists such that their Bitwise XOR exceeds both the ranges | Function to check if there exists any pair ( P , Q ) whose Bitwise XOR is greater than the Bitwise XOR of X and Y ; Stores the Bitwise XOR of X & Y ; Traverse all possible pairs ; If a pair exists ; If a pair is found ; Driver Code
def findWinner ( X , Y ) : NEW_LINE INDENT playerA = ( X ^ Y ) NEW_LINE flag = False NEW_LINE for i in range ( 1 , X + 1 , 1 ) : NEW_LINE INDENT for j in range ( 1 , Y + 1 , 1 ) : NEW_LINE INDENT val = ( i ^ j ) NEW_LINE if ( val > playerA ) : NEW_LINE INDENT flag = True NEW_LINE break NEW_LINE DEDENT DEDENT if ( flag ) : NEW_LINE INDENT break NEW_LINE DEDENT DEDENT if ( flag ) : NEW_LINE INDENT print ( " Yes " ) NEW_LINE DEDENT else : NEW_LINE INDENT print ( " No " ) NEW_LINE DEDENT DEDENT if __name__ == ' _ _ main _ _ ' : NEW_LINE INDENT A = 2 NEW_LINE B = 4 NEW_LINE findWinner ( A , B ) NEW_LINE DEDENT