Full day trip to NYU, where you listen to several interesting lectures by NYU CS professors. The topics are interesting, and food will be provided. It is not open to Seniors (sorry...)
If you are and interested JUNIOR please fill out this form:
Your goal is to write a knight's tour solver. This is due the Tuesday after break.
Place it in your git repo:
KnightBoard has 2 public methods and a constructor, a private helper is needed as well.
public KnightBoard(int startingRows,int startingCols)
public String toString() //blank if you never called solve or when there is no solution
public void solve()
private boolean solveH(int row ,int col, int level) // level is the # of the knight
*Use the following format for toString:
(THESE ARE NOT VALID SOLUTIONS, They JUST TO DEMONSTRATE FORMAT)
Single spaces between numbers, but leading spaces on single digit 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
So it looks like this:
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).
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 certainly possible when none of those are true!!!!!
Your solve should work on 7x7 easily.
Here is something as a bonus: