The 8 queens problem asks: In how many ways can 8 queens be placed on an 8×8 chessboard so that no two queens attack each other? A queen can attack any piece in the same row, column, or diagonal.
The answer is 92 distinct solutions. If we exclude rotations and reflections that map solutions onto each other, there are 12 fundamentally distinct configurations.
This problem is a standard exercise in:
- Constraint satisfaction
- Recursive backtracking
- Python closures and nested functions
It generalizes to the N queens problem, where the goal is to place N queens on an N×N board. Python's clean syntax makes it an ideal language for demonstrating the algorithm clearly.