title: knight's tour efficient solution
body: <p>I have build a code in prolog to find a series of legal moves in which the knight lands on each square of the chessboard(8x8) exactly once.</p>
  
  <p>I have used a logic like below:
  There 8 types of knight moves:</p>
  
  <ul>
  <li>right 1 down 2</li>
  <li>left 1 down 2</li>
  <li>right 2 down 1 </li>
  <li>left 2 down 1</li>
  <li>right 1 up 2 </li>
  <li>left 1 up 2</li>
  <li>right 2 up 1</li>
  <li>left 2 up 1</li>
  </ul>
  
  <p>right 1 down 2 moves:</p>
  
  <pre><code> move(X,Y) :- 
      C_X is X mod 8,      
          R_X is X // 8,       
          C_Y is C_X + 1,      % 1 right
          C_Y &lt; 8,           
          R_Y is R_X + 2,      % 2 down
      R_Y &lt; 8,
          Y is R_Y * 8 + C_Y,
      Y &gt;= 0,
      X &gt;= 0,
      X &lt; 64,
      Y &lt; 64.
  </code></pre>
  
  <p>And this is repeated for all 8 types of moves</p>
  
  <p>The problem is that my code is not efficient, it takes too much steps to find the right path.
  Does anyone know an efficient way of solving this problem?</p>