% N-queens problem by Ilkka Niemelä; % modified by Tomi Janhunen to place queens row-by-row % % d(1..n) describe the dimensions of the board % q(X,Y) gives the legal positions of the queens d(1..n). % Place a queen on each row { q(X,Y) : d(X) } :- d(Y). :- q(X,Y), q(Z,Y), d(X;Y;Z), X