Function to return the required position
#include <bits/stdc++.h> NEW_LINE using namespace std ; int noOfSquares ( int x1 , int y1 , int x2 , int y2 ) { int dx = abs ( x2 - x1 ) ; int dy = abs ( y2 - y1 ) ; int ans = dx + dy - __gcd ( dx , dy ) ; cout << ans ; }