Is there a way for a chess knight to start at the top-left corner from a N x N chessboard, visit all the squares of the board exactly once and end at the lower-right corner.
We need to traverse all the squares of the chessboard exactly once. Also, the moves of the knight are L-shaped, that is, traverse two squares vertically or horizontally. A simple observation to take from this is that in one move, the knight starts and ends at two different colored squares.
Consider two cases:
Case N is even: Let the value of N be 8. Hence, total number of squares on the board will be 64. Now, to visit all the squares of the board exactly once the knight would have to make 63 moves. Since, total number of moves are odd, the journey will start and end on the squares of the opposite color. Since, the squares on the top-left corner and lower-right corner are both coloured the same, hence the journey is impossible.
Case N is odd: Let the value of N be 9. Hence, total number of squares on the board will be 81. Now, to visit all the squares of the board exactly once the knight would have to make 80 moves. Since, total number of moves are even, the journey will start and end on the squares of the same color. Since, the squares on the upper-left corner and lower-right corner are of the same color, hence the journey on 9 x 9 board is possible. But for N = 3, this is no solution as the knight cannot reach (2,2) position (which is the middle of chessboard).
Hence, on a N x N chessboard, a knight will have to make (N2 – 1) moves to visit each square exactly once. So, if N is even, the journey is impossible and for odd values of N, the journey is possible.
- Count of all possible ways to reach a target by a Knight
- Minimum steps to reach target by a Knight | Set 1
- Minimum steps to reach target by a Knight | Set 2
- Number of blocks in a chessboard a knight can move to in exactly k moves
- The Knight's tour problem | Backtracking-1
- Probability of Knight to remain in the chessboard
- Warnsdorff's algorithm for Knight’s tour problem
- Possible moves of knight
- Puzzle | Dividing a Square into N smaller squares
- Puzzle | Three Squares
- Count the total number of squares that can be visited by Bishop in one move
- Total position where king can reach on a chessboard in exactly M moves
- Total position where king can reach on a chessboard in exactly M moves | Set 2
- Puzzle 15 | (Camel and Banana Puzzle)
- Puzzle 24 | (10 Coins Puzzle)
- Puzzle 27 | (Hourglasses Puzzle)
- Puzzle 28 | (Newspaper Puzzle)
- Puzzle 29 | (Car Wheel Puzzle)
- Puzzle 31 | (Minimum cut Puzzle)
- Puzzle 33 | ( Rs 500 Note Puzzle )
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to firstname.lastname@example.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.
Improved By : devgupta2000266