Backtracking/Knight's Tour/C/Knightstour.c
//there can be more solutions other than this
there can be more solutions other than this
there can be more solutions other than this
bool solveKT() 
{ 
    int sol[N][N]; 
    for (int x = 0; x < N; x++) 
        for (int y = 0; y < N; y++) 
            sol[x][y] = -1; 
    int xMove[8] = {  2, 1, -1, -2, -2, -1,  1,  2 }; 
    int yMove[8] = {  1, 2,  2,  1, -1, -2, -2, -1 }; 
    sol[0][0]  = 0; 
    if (solveKTUtil(0, 0, 1, sol, xMove, yMove) == false) 
    { 
        printf("Solution does not exist"); 
        return false; 
    } 
    else
        printSolution(sol); 
    return true; 
}
bool solveKT ( ) { int sol [ N ] [ N ] ; for ( int x = 0 ; x < N ; x ++ ) for ( int y = 0 ; y < N ; y ++ ) sol [ x ] [ y ] = -1 ; int xMove [ 8 ] = { 2 , 1 , -1 , -2 , -2 , -1 , 1 , 2 } ; int yMove [ 8 ] = { 1 , 2 , 2 , 1 , -1 , -2 , -2 , -1 } ; sol [ 0 ] [ 0 ] = 0 ; if ( solveKTUtil ( 0 , 0 , 1 , sol , xMove , yMove ) == false ) { printf ( " " ) ; return false ; } else printSolution ( sol ) ; return true ; }
there can be more solutions other than this
there can be more solutions other than this
// Since the Knight is initially at the first block 