row(1..5).
col(1..5).
1 { q(I, J) : row(I)} 1 :- 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.
#show q/2.
Resource created Thursday 24 October 2019, 01:47:02 PM, last modified Thursday 24 October 2019, 01:48:07 PM.
file: nqueens2.lp