Check if it is possible to reach destination in even number of steps in an Infinite Matrix | Function to check destination can be reached from source in even number of steps ; Coordinates differences ; Minimum number of steps required ; Minsteps is even ; Minsteps is odd ; Driver Code ; Given Input ; Function Call
def IsEvenPath ( Source , Destination ) : NEW_LINE INDENT x_dif = abs ( Source [ 0 ] - Destination [ 0 ] ) NEW_LINE y_dif = abs ( Source [ 1 ] - Destination [ 1 ] ) NEW_LINE minsteps = x_dif + y_dif NEW_LINE if ( minsteps % 2 == 0 ) : NEW_LINE INDENT print ( " Yes " ) NEW_LINE DEDENT else : NEW_LINE INDENT print ( " No " ) NEW_LINE DEDENT DEDENT if __name__ == ' _ _ main _ _ ' : NEW_LINE INDENT Source = [ 2 , 1 ] NEW_LINE Destination = [ 1 , 4 ] NEW_LINE IsEvenPath ( Source , Destination ) NEW_LINE DEDENT