liveBook · Manning

N-queens problem

The n-queens problem is the puzzle of placing n queens on an n-by-n chessboard so that no two queens attack each other.

How 2 Manning books explain it

Quantum Programming in Depth

The N queens puzzle is the problem of placing N chess queens on an N-by-N board so that no two queens attack each other.

How it is used
Frames Grover search as a constraint-satisfaction task requiring a representation, state preparation, and marking oracle.
How deep it goes
Derives three encodings, their search spaces and oracle checks, then compares resource estimates for a 10-queen instance.
Examples
Uses valid and invalid 4 × 4 placements and evaluates alternative quantum encodings for 10 queens.
What you can do after
Evaluate encoding tradeoffs by relating constraint structure to oracle complexity, register size, and estimated quantum resources.

Read how Quantum Programming in Depth explains n-queens problem →

Optimization Algorithms: AI techniques for design, planning, and control problems

The n-queens problem is the puzzle of placing n queens on an n-by-n chessboard so that no two queens share a row, column, or diagonal.

How it is used
Uses queen placement as a compact constraint-satisfaction example and as a test problem for tabu search.
How deep it goes
Defines the constraints, works through six tabu-search iterations, and supplies Python functions, but does not develop formal correctness proofs.
Examples
Demonstrates 4-by-4 and 7-queens boards, collision-count reductions, swap moves, figures, and Python-generated configurations.
What you can do after
Apply it via Python by representing configurations, counting attacks, exploring moves, maintaining tabu tenure, and stopping after non-improvement.

Read how Optimization Algorithms: AI techniques for design, planning, and control problems explains n-queens problem →

Related concepts

Questions about n-queens problem

What is n-queens problem?

The n-queens problem is the puzzle of placing n queens on an n-by-n chessboard so that no two queens attack each other.

Which Manning books explain n-queens problem?

Quantum Programming in Depth and Optimization Algorithms: AI techniques for design, planning, and control problems.

What is n-queens problem a kind of?

N-queens problem is a kind of constraint-satisfaction problem. A constraint-satisfaction problem is a problem defined by variables, domains of possible values, and constraints, with the goal of finding an assignment that satisfies the constraints.

These guides are generated from the text of Manning books by Manning's knowledge graph and link to the sections they draw on. The full books are available on liveBook and at manning.com.