Solving the N-Queens problem
Originally known as the eight-queen puzzle, the classic N-Queens problem originated from the game of chess, and the 8x8 chessboard was its early playground. The task was to place eight chess queens on the board without any two of them threatening each other. In other words, no two queens can share the same row, same column, or same diagonal. The N-Queens problem is similar, using an N×N chessboard and N chess queens.
The problem is known to have a solution for any natural number, n, except for the cases of n=2 and n=3. For the original eight-queen case, there are 92 solutions, or 12 unique solutions if we consider symmetrical solutions to be identical. One of the solutions is as follows:
Figure 5.1: One of the 92 possible solutions for the eight-queen puzzle
By applying combinatorics, the count of all possible ways to place eight pieces on the 8×8 board yields 4,426,165,368 combinations. However, if we can create...