Modus Manual
Simulation Speed Slow

Boardsize N x N

Number of solutions found: 0


The 8 Queens problem was formulated in 1848 by the Bavarian chess player Max Bezzel. He raised the question of how many solutions could be found to place 8 queens on a chess board in a way that no one of the queens captures another one. The answer is 92. As you probably know, a queen captures another queen if they are in the same row, column, or in the same diagonal.

How to find all solutions systematically ?

By using "backtracking" - an algorithmus or set of clear defined instructions and by the way a classical subject for computer science students.

How does it work ?

We start with an empty board and place a queen on the first column in the first row. We continue with the next available column and place the next queen onto the next available square (row). Continue with this scheme. If you do not find a possible square, you have to remove the last queen in this column and move the queen on the previous column to the next available free square (row). That is the backtracking part of the algorithm. Continue in this fashion until you have placed all N queens and have found the first solution.

Use the Simulation

You can nicely observe the operation of the algorithm if you select the "Simulation Modus" and a board size of "8x8". Start with a "Slow Simulation Speed". Once you understand the principle of the algorithm, you can increase the "Simulation Speed". Be patient, it takes some time to find all solutions. The solutions are listed in the form [1 5 8 6 3 7 2 4]. That means for this example that the first queen is placed in the first colum first row, the second queen is placed in the second column fifth row and so on.

Try yourself !

Select the "Manual Modus" and see how many solutions you can find for the other board sizes.
Have fun !