Source to destination in 2 | C ++ implementation of the approach ; Function that returns true if it is possible to move from source to the destination with the given moves ; Driver code
#include <bits/stdc++.h> NEW_LINE using namespace std ; bool isPossible ( int Sx , int Sy , int Dx , int Dy , int x , int y ) { if ( abs ( Sx - Dx ) % x == 0 and abs ( Sy - Dy ) % y == 0 and ( abs ( Sx - Dx ) / x ) % 2 == ( abs ( Sy - Dy ) / y ) % 2 ) return true ; return false ; } int main ( ) { int Sx = 0 , Sy = 0 , Dx = 0 , Dy = 0 ; int x = 3 , y = 4 ; if ( isPossible ( Sx , Sy , Dx , Dy , x , y ) ) cout << " Yes " ; else cout << " No " ; return 0 ; }