October 25, 1990; Peter A. Bigot
This file is in the public domain.
This program solve the non-attacking n-queens problem for (square) boards
of arbitrary size. The problem consists of placing chess queens on an
n-by-n grid such that no queen is in the same row, column, or diagonal as
any other queen. The output is each of the solution boards; rotations
not considered equal. An example of the output for n:
-----------------
|Q| | | | | | | |
-----------------
| | | | | | |Q| |
-----------------
| | | | |Q| | | |
-----------------
| | | | | | | |Q|
-----------------
| |Q| | | | | | |
-----------------
| | | |Q| | | | |
-----------------
| | | | | |Q| | |
-----------------
| | |Q| | | | | |
-----------------
Usage: genqueen n
where n is the number of rows / columns in the board. The default for n
is 6.
Source code |
Program Library Page |
Icon Home Page