#include #include #include #include #include #include #include //UL, UR, R, LR, LL, L #define MIN 2000 static int y[6] = {-1, +1, +2, +1, -1, -2}; static int x[6] = {-2, -2, 0, +2, +2, 0}; const char *pathStr[6] = {"UL", "UR", "R", "LR", "LL", "L"}; int vis[201][201]; int path[MIN]; int min = MIN; int isSafe(int nx, int ny, int n) { return ((nx>=0 && nx=0 &&nymin) return 0; if(cx == dx && cy == dy) { if (min>cval) { min = cval; return 1; } return 0; } //printf("%d %d\n", cx, cy); int safe = 0; vis[cx][cy] = cval; for(int i = 0;i<6;i++){ int nx = cx + x[i]; int ny = cy + y[i]; if(isSafe(nx, ny, n) && vis[nx][ny]>cval && printUtil(n, nx, ny, dx, dy, cval+1)) { path[cval] = i; safe = 1; //return 1; } } return safe; } void printShortestPath(int n, int i_start, int j_start, int i_end, int j_end) { // Print the distance along with the sequence of moves. for(int i = 0; i