symbol(1..9).
cell(1..9, 1..9).


1 { write(I, J, X) : symbol(X) } 1 :- cell(I, J).

%within column
:- write(I, J, X), write(I, K, X), J != K.

%within row
:- write(I, J, X), write(K, J, X), I != K.

%within subsquare
samesquare(I, J, K, L) :- cell(I, J), cell(K, L), (I+2)/3 = (K+2)/3, (J+2)/3 = (L+2)/3.
:- write(I, J, X), write(K, L, X), samesquare(I, J, K, L), I!=K.
:- write(I, J, X), write(K, L, X), samesquare(I, J, K, L), J!=L.

Resource created Thursday 24 October 2019, 01:49:09 PM.

file: sudoku.lp


Back to top

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