next up previous
: この文書について...

CSL102: Introduction to Computer Science
II semester 2004-05
Backtracking algorithms: The Knight's tour

Assume an $ n\times n$ chess board with squares numbered from $ (0,0)$ to $ (n-1, n-1)$. Assume a knight starts from the square $ (0,0)$ and tries to traverse the entire chess board by stopping on each square exactly once. The knight follows its usual L-shaped move as in chess. Hence a knight on square $ (0,0)$ can move to one of the squares $ (1, 2)$ or $ (2, 1)$ only. A successful knight's tour is the path traversed by the knight, represented as a list of squares. In general, depending upon the value of $ n$ and the starting point, there may exist 0 or more successful knight's tours.

Write a function knight_tour which takes $ n$ as a parameter and outputs the list of all possible successful knight's tours.

Note:

  1. You are not allowed to change any of the names given in the signature. You are not even allowed to change upper-case letters to lower-case letters or vice-versa.
  2. You may define any new functions you like in the structure besides those mentioned in the signature.
  3. Your program should work with the given signature.
  4. You need to think of the most efficient way of implementing the various functions given in the signature so that the function results satisfy their definitions and properties.
  5. Since the evaluator is going to look at your source code before evaluating it, you must explain your algorithms in the form of ML comments, so that the evaluator can understand what you have implemented.
  6. Do not add any more decorations or functions or user-interfaces in order to impress the evaluator of the program. Nobody is going to be impressed by it.
  7. There is a serious penalty for copying. If it is felt that there is too much similarity in the code between any two persons, then both are going to be penalized equally. So please set permissions on your directories, so that others cannot copy your programs.



next up previous
: この文書について...
S Arun-Kumar 平成17年3月28日