Function Repository Resource:

# NQueenSolution

Give the solution to the n-queen problem

Contributed by: Aster Ctor
 ResourceFunction["NQueenSolution"][n] gives the solution to the n-queen problem.

## Details and Options

The n-queens problem consists of putting n queens on an n×n chessboard such that no two queens attack one another.
The solution is a list of numbers of length n, which indicates the position within each column where the queen should be placed.
The option Method supports the following types:
 "Unique" show only one solution "All" show all solutions "CountAll" give the number of all solutions

## Examples

### Basic Examples (2)

Get one of the solutions to the 8-queens problem:

 In[1]:=
 Out[1]=

Visualize this solution:

 In[2]:=
 Out[3]=

### Scope (3)

Get all the solutions to the 8-queens problem:

 In[4]:=
 Out[5]=

Count the number of solutions:

 In[6]:=
 Out[6]=

Compute the number of solutions directly:

 In[7]:=
 Out[7]=

### Neat Examples (2)

Display the solution with a beautiful chessboard:

 In[8]:=

View the solution:

 In[9]:=
 Out[9]=

## Publisher

Aster Ctor (MoeNet)

## Version History

• 1.0.0 – 27 December 2019