Check if possible to move from given coordinate to desired coordinate | Python program to check if it is possible to reach ( a , b ) from ( x , y ) . Returns GCD of i and j ; Returns true if it is possible to go to ( a , b ) from ( x , y ) ; Find absolute values of all as sign doesn 't  matter. ; If gcd is equal then it is possible to reach . Else not possible . ; Driven Program Converting coordinate into positive integer
def gcd ( i , j ) : NEW_LINE INDENT if ( i == j ) : NEW_LINE INDENT return i NEW_LINE DEDENT if ( i > j ) : NEW_LINE INDENT return gcd ( i - j , j ) NEW_LINE DEDENT return gcd ( i , j - i ) NEW_LINE DEDENT def ispossible ( x , y , a , b ) : NEW_LINE INDENT x , y , a , b = abs ( x ) , abs ( y ) , abs ( a ) , abs ( b ) NEW_LINE return ( gcd ( x , y ) == gcd ( a , b ) ) NEW_LINE DEDENT x , y = 35 , 15 NEW_LINE a , b = 20 , 25 NEW_LINE if ( ispossible ( x , y , a , b ) ) : NEW_LINE INDENT print " Yes " NEW_LINE DEDENT else : NEW_LINE INDENT print " No " NEW_LINE DEDENT