Question: Using swi prolog code a tail-recursive solution for the nqueens problem. The nqueens problem is placing N amount of queens on an NxN chess board
Using swi prolog code a tail-recursive solution for the nqueens problem.
The nqueens problem is placing N amount of queens on an NxN chess board so that none of them are attacking each other.
The position of the queens should be represented as a list where the index of the list is the column and the integer is the row. i.e. [6,7,3,2,8]. A queen is found on the 6th row of the first column.
Do not use cut (!) or constraint logic libraries please. Not quite there in my learning process.
Example run
?- queens(8, Qs).
Qs = [4, 2, 7, 3, 6, 8, 5, 1];
Qs = [5, 2, 4, 7, 3, 8, 6, 1];
....
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
