N-Queens Solver

Place N queens on an N×N board so none attack each other, and count all the solutions.

Runs in your browser. Your files never leave your device. See how to check

…

How to do it

  1. 1
    Step 1: Open N-Queens Solver and add your input

    Type your numbers or text, add your file, or pick the options you need. Nothing is uploaded: everything stays in your browser.

  2. 2
    Step 2: What N-Queens Solver does

    Place N queens on an N×N board so none attack each other, and count all the solutions.

  3. 3
    Step 3: Read the result and compare

    The result appears at once. Change one value to see how the answer moves, then keep the figure that fits your case.

  4. 4
    Step 4: Copy or save it

    Copy the result or download it. For an important decision, confirm it with the official source or an adviser.

About this tool

Enter the board size N from 1 to 14. The solver finds the first arrangement of N non-attacking queens, draws it and counts all distinct solutions.

Method

Queens are placed row by row with a backtracking search that tracks attacked columns and both diagonals in bit masks. Every solution is counted, not just the first.

Counts

N = 4 has 2 solutions, 5 has 10, 6 has 4, 8 has 92, 10 has 724, 12 has 14,200 and 14 has 365,596. N = 2 and 3 have none.

Worked example

On an 8×8 board there are 92 solutions. The first has queens in columns 1 5 8 6 3 7 2 4 of rows 1 to 8.

Tips for best results

Check every box before you rely on a result, because one wrong digit changes the whole answer. Use the exact figures from your payslip, bill, certificate or contract, and keep a note of the date you calculated. Rates, thresholds and rules change from time to time, so for tax, fees and legal matters treat the output as an estimate and confirm with the official source named on this page. You can run as many scenarios as you like; nothing is saved or sent, and refreshing the page clears the boxes.

Quick facts

Embed this calculator on your site

Copy this code to show the calculator on your own page. A link back to shobfree.com is included.

Frequently asked questions

Is there always a solution?

For every N except 2 and 3.

Why stop at 14?

The number of solutions explodes; 14 already counts 365,596 in the browser.

Are rotations counted separately?

Yes, all 92 solutions for N = 8 include rotations and reflections (12 are fundamentally different).

What does the list of columns mean?

The column of the queen in each row.

Guides for this tool

Completely freeNo cost, no sign-up
Files stay privateEverything runs in your browser
Easy in your languageAvailable in many languages