For each of the following chess pieces, find the minimum number of colors needed to color an N x N chessboard, such that no pair placed on two squares of the same color can threaten each other:
- The knight
- The bishop
- The king
- The rook
The knight in a chessboard threatens any square that is two squares horizontally and one square vertically, or two squares vertically and one square horizontally from the square it occupies.
As depicted in the figure, on the standard chessboard, a knight in a white square can only attack black square and vice-versa. Hence, for the knight, the minimum number of colors is 2 for N > 2. It is 1 for N = 2, as no two knights can threaten each other on such a small board.
The bishop is the one that threatens any square which is on the same diagonal.
Now, since there are N squares on the main diagonal, hence at least N colors are required to color the squares of the diagonal so that no bishops on the diagonal threaten each other. To extend this coloring to the entire board, we can color either the columns or the row, with the same color, as its square lying on the main diagonal. In this way, all the diagonals will have different colored squares, so no two bishops lying on two same-colored squares will threaten each other.
All the squares that are horizontally, vertically or diagonally adjacent to the square of the king, are threatened by it.
Consider a 2 x 2 chessboard, with a king in its lower-left corner. Since such a king would threaten all the remaining squares on the board. Hence, 4 colors will be needed to color a 2 x 2 board.
To color an N x N chessboard, we can consider it as being made up 2 x 2 boards, and coloring each 2 x 2 board with the same coloring scheme, will ensure that no two kings on the same-colored squares threaten each other. Hence, the number of colors for the king is 4.
A rook threatens every square that lies on the same row or column, on the chessboard.
To ensure that a rook doesn’t threaten anyone in its row or column, N colors are required. Also, N colors are sufficient to color the entire board, using a simple coloring scheme. Color the first row with N different colors. For each subsequent row to be colored, circularly shift the colors by one position, left or right, so that no row contains the same color twice.
- Puzzle 25 | (Chessboard and dominos)
- Puzzle | Maximum number of Kings on Chessboard without under check
- Check if the given chessboard is valid or not
- Check if a Queen can attack a given cell on chessboard
- Puzzle 31 | (Minimum cut Puzzle)
- Minimum number of moves required to solve a Jigsaw Assembly Puzzle
- Puzzle | Minimum time required to make N Pancakes
- Probability of Knight to remain in the chessboard
- Maximum bishops that can be placed on N*N chessboard
- Number of blocks in a chessboard a knight can move to in exactly k moves
- Total position where king can reach on a chessboard in exactly M moves
- Chessboard Pawn-Pawn game
- Total position where king can reach on a chessboard in exactly M moves | Set 2
- Maximum non-attacking Knights that can be placed on an N*M Chessboard
- Maximum non-attacking Rooks that can be placed on an N*N Chessboard
- Find position of non-attacking Rooks in lexicographic order that can be placed on N*N chessboard
- Count positions in a chessboard that can be visited by the Queen which are not visited by the King
- Check if any King is unsafe on the Chessboard or not
- Find all the queens attacking the king in a chessboard
- Puzzle | Number of Sheets to be turned so that Prime Number has a Vowel on the other side
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to email@example.com. 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.