Experimental

N-Queens Solver

Solve the n-queens problem for any board size, count all distinct solutions, and see how much work backtracking saves against checking every arrangement.

Last reviewed by the Radiatus Cloud team

Results appear here.

Need this done properly for your business?

Radiatus delivers secure cloud, DevOps & compliance engineering.

Book a free consult

The interest is in how few arrangements need checking

Placing eight queens so none attacks another has 92 solutions, and finding them by examining every way to put eight queens on sixty-four squares would mean checking more than four billion arrangements. Backtracking checks about two thousand. The saving comes from abandoning a branch the moment it becomes impossible rather than completing it and testing at the end, and that single idea is the whole of constraint search. Watching the ratio grow with board size is the clearest demonstration of why it matters.

The counts have no formula

There are 92 solutions for eight queens, 724 for ten, 14200 for twelve, and 2.28 times ten to the fifteen for twenty-seven, which took a distributed computation years to establish. No closed form is known and none is expected; the sequence is computed rather than derived. That is unusual for a problem this easy to state, and it is why the counts are still being pushed forward one board size at a time.

Two and three queens are impossible

There is no solution for a two by two or three by three board, and there is at least one for every size from four upward. The small impossible cases are worth seeing because they are the only sizes where exhaustive search is small enough to check by hand, and they make the constraint concrete: on three squares a side, the diagonals reach everywhere the rows and columns do not.

Related tools

Frequently Asked Questions

How many solutions are there for eight queens?

92 in total, or 12 if you count solutions that are rotations and reflections of each other as the same.

Why is backtracking so much faster?

Because it abandons a partial placement the moment it becomes impossible rather than completing it and testing at the end. For eight queens that is roughly two thousand checks against more than four billion arrangements.

Is there a formula for the number of solutions?

No, and none is expected. The counts are computed board size by board size, and the largest known took a distributed computation years to establish.

Which board sizes have no solution?

Two and three. Every size from four upward has at least one solution.

What is a fundamental solution?

One representative of a group of solutions related by rotation and reflection. Eight queens has 92 solutions and 12 fundamental ones.

Privacy & Security

Everything runs in your browser; nothing is uploaded.

Data: None
Client-side-Side
Active
v1.0

How to Use

Choose a board size to find solutions.

Disclaimer: This tool is provided "as is" without warranty of any kind. Results are for educational and utility purposes.