row(1..5).
col(1..5).

{ q(I, J) } :- row(I), col(J).

:- q(I, J), q(I, K), J != K.
:- q(I, J), q(K, J), I != K.
:- q(I, J), q(K, L), I != K, K-I = L-J.
:- q(I, J), q(K, L), I != K, K-I = J-L.
5 { q(I, J) : row(I), col(J) }.

#show q/2.

Resource created Tuesday 08 September 2020, 12:30:02 PM.

file: nqueens.lp


Back to top

COMP4418 20T3 (Knowledge Representation and Reasoning) is powered by WebCMS3
CRICOS Provider No. 00098G