Check if point ( X , Y ) can be reached from origin ( 0 , 0 ) with jump of 1 and N perpendicularly simultaneously | Function to check if ( X , Y ) is reachable from ( 0 , 0 ) using the jumps of given type ; Case where source & destination are the same ; Check for even N ( X , Y ) is reachable or not ; If N is odd and parity of X and Y is different return , no valid sequence of jumps exist ; Driver Code
def checkReachability ( N , X , Y ) : NEW_LINE INDENT if ( X == 0 and Y == 0 ) : NEW_LINE INDENT return " YES " NEW_LINE DEDENT if ( N % 2 == 0 ) : NEW_LINE INDENT return " YES " NEW_LINE DEDENT else : NEW_LINE INDENT if ( X % 2 != Y % 2 ) : NEW_LINE INDENT return " NO " NEW_LINE DEDENT else : NEW_LINE INDENT return " YES " NEW_LINE DEDENT DEDENT DEDENT if __name__ == ' _ _ main _ _ ' : NEW_LINE INDENT N = 2 NEW_LINE X = 5 NEW_LINE Y = 4 NEW_LINE print ( checkReachability ( N , X , Y ) ) NEW_LINE DEDENT