Objective is to get minimum number of steps for a Knight to reach far right hand side corner. Also trace the path he travels.
For example : If we have a 3 X 3 chessboard, (x,y) represents the Knight's initial position.
-
If (x,y) is (2,2), an exception needs to be thrown as a Knight starting at that place can never reach (3,3).
-
If (x,y) is (1,1), the minimum number of moves in which it reaches (3,3) is 4 and the path also will be printed out.
-
So, the input can be any position, valid or invalid, minimum number of moves and the path will be printed accordingly.
The solution provided is scalable and is not limited to a 3 X 3 chessboard.