1 8 15 22
3 10 19 64
16 23 2
9 18 21 4 11
7 14 17 24
5 12 63 20
34 25 6 13
44 27 52 61
55 46 33 26
53 62 43 28
32 35 54 45
40 29 60 51
47 56 37 30
49 58 39 42
36 31 48 57
38 41 50 59
Your code should print out a solution in a format similar to the above.
When debugging your program, run it on a smaller size chessboard so that it runs faster. There is a valid tour on a 5x5 chessboard.
Your recursive code could take significant amounts of time to run quickly on an 8x8 chessboard (or larger). To receive full credit, it should take no longer than 2 minutes to run on one of the slower departmental machines (e.g. those in CMC 306). To speed up the program, a good method is to order the list of squares to which it can move from a given position so that it will first try to go to the squares with the least accessibility, that is, to the squares from which there are the fewest knight's moves to squares not yet visited.
Have fun and good luck!
(Much of the text of this problem was adapted from Kruse & Ryba, Data Structures and Program Design in C++, (c) 1999, P. 197 Problem P4.)