knight's tour : not able to resolve
<p>I wrote this code to print one of the possible knight's tour such that every place is visited exactly once.</p>

<pre><code>public class Main{
         static int move[][]=new int[8][8];
         static int X[]={1 , 2 , 2 , 1 ,-1 ,-2 ,-2,-1};
         static int Y[]={2 , 1 ,-1 ,-2 ,-2 ,-1 , 1, 2};
         static boolean printMove(int x,int y,int step){
   if(step==65){

       return true;
   }
   else{
       int x1,y1;

       for(int l=0;l&lt;8;l++){
           x1=x+X[l];
           y1=y+Y[l];
           if(x1&lt;8&amp;&amp;y1&lt;8&amp;&amp;x1&gt;=0&amp;&amp;y1&gt;=0&amp;&amp;move[x1][y1]==0){

               move[x1][y1]=step;
               if(printMove(x1,y1,step+1)){
                   return true;
               }
               else
               move[x1][y1]=0;


           }
       }
       return false;

   }
} 

 static void printSteps(){
       for(int i=0;i&lt;8;i++){
          for(int j=0;j&lt;8;j++){
               System.out.print(move[i][j]+" ");
             }
           System.out.println();
             }
    }
public static void main(String args[]){

     move[0][0]=1;

     printMove(0,0,2);   
     printSteps();


   }
}
</code></pre>

<p>this code is working but the following code is not working, I made little change in X[] and Y[] which should not effect the algorithm.</p>

<pre><code>    public class Main{
         static int move[][]=new int[8][8];
         static int X[]={-1, 1 , 2 , 2 , 1 ,-1 ,-2 ,-2};
         static int Y[]={ 2, 2 , 1 ,-1 ,-2 ,-2 ,-1 , 1};
         static boolean printMove(int x,int y,int step){
   if(step==65){

       return true;
   }
   else{
       int x1,y1;

       for(int l=0;l&lt;8;l++){
           x1=x+X[l];
           y1=y+Y[l];
           if(x1&lt;8&amp;&amp;y1&lt;8&amp;&amp;x1&gt;=0&amp;&amp;y1&gt;=0&amp;&amp;move[x1][y1]==0){

               move[x1][y1]=step;
               if(printMove(x1,y1,step+1)){
                   return true;
               }
               else
               move[x1][y1]=0;


           }
       }
       return false;

   }
} 

 static void printSteps(){
       for(int i=0;i&lt;8;i++){
          for(int j=0;j&lt;8;j++){
               System.out.print(move[i][j]+" ");
             }
           System.out.println();
             }
    }
public static void main(String args[]){

     move[0][0]=1;

     printMove(0,0,2);   
     printSteps();


   }
}
</code></pre>

<p>I just changed </p>

<pre><code>         static int X[]={1 , 2 , 2 , 1 ,-1 ,-2 ,-2,-1};
         static int Y[]={2 , 1 ,-1 ,-2 ,-2 ,-1 , 1, 2};
</code></pre>

<p>to</p>

<pre><code>         static int X[]={-1, 1 , 2 , 2 , 1 ,-1 ,-2 ,-2};
         static int Y[]={ 2, 2 , 1 ,-1 ,-2 ,-2 ,-1 , 1};
</code></pre>
