Your goal is to write a knight's tour solver. This is due the Tuesday after break.
Place it in your git repo:
1. Assume all boards are square and write a solution as follows.
KnightBoard has 3 public methods that matter:
constrctor and two other methods
void printSolution() //display a solution in the following format:
(THESE ARE NOT VALID SOLUTIONS, They JUST TO DEMONSTRATE FORMAT)
Single spaces between numbers:
1 2 5
3 4 6
7 8 9
When there are two digit numbers (rows*cols >= 10) Put a leading space in front of single digit numbers:
(spaces replaced with _ to show the difference)
_1 _2 15 _6
_3 _4 _7 11
_8 _9 10 12
13 14 _5 16
*I will not be testing boards that have a rows*cols that is >= 100, as the program would take a long time to complete.
-You only have to step on every square exactly once, starting on the 1st square counts.
-You do not have to come back to where you started. This is called a closed tour (it is a loop that is closed) and closed tours take much longer to find (potentially).
Your tour should work on 5x5,6x6, and 7x7 easily.
2. Allow for a construction of a rectangular board!
KnightBoard(int cols, int rows)
The other methods should still work correctly.
This means you can find more solutions without giant boards.
Any m × n board with m ≤ n, a closed knight's tour is always possible unless one or more of these three conditions are met:
This also means an open tour is at least possible when none of those are true!!!!!
Test other sizes now: