human
Check if a destination is reachable from source with two movements allowed | Set 2 | Check if ( x2 , y2 ) can be reached from ( x1 , y1 ).
Reduce x2 by y2 until it is less than or equal to x1.
Reduce y2 by x2 until it is less than or equal to y1.
If x2 is reduced to x1.
Check if y2 can be reduced to y1 or not.
If y2 is reduced to y1.
Check if x2 can be reduced to x1 or not.
Driver Code"
How can the above be solved in Python?
assistant
#Here is code to check if a destination is reachable from source with two movements allowed and the other steps required.
 def isReachable ( x1 , y1 , x2 , y2 ) :
	while ( x2 > x1 and y2 > y1 ) :
		if ( x2 > y2 ) :
			x2 %= y2
		else :
			y2 %= x2
	if ( x2 == x1 ) :
		return ( y2 - y1 ) >= 0 and ( y2 - y1 ) % x1 == 0
	elif ( y2 == y1 ) :
		return ( x2 - x1 ) >= 0 and ( x2 - x1 ) % y1 == 0
	else :
		return 0
source_x = 2
source_y = 10
dest_x = 26
dest_y = 12
if ( isReachable ( source_x , source_y , dest_x , dest_y ) ) :
	print ( " Yes " )
else :
	print ( " No " )