

Solve the eight queens puzzle.



You can extend the problem to solve the puzzle with a board of size   NxN.

For the number of solutions for small values of   N,   see   OEIS: A000170.



Related tasks

 A* search algorithm
 Solve a Hidato puzzle
 Solve a Holy Knight's tour
 Knight's tour
 Peaceful chess queen armies
 Solve a Hopido puzzle
 Solve a Numbrix puzzle
 Solve the no connection puzzle


solution[board] :=
{
    for q = 0 to length[board] - 1
        for c = q+1 to length[board] - 1
            if board@q == board@c + (c - q) or board@q == board@c - (c - q)
                return false
    return true
}
 
for b = array[1 to 8].permute[]
    if solution[b]
        println[b]