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 Tuesday 08 September 2020, 12:30:02 PM.
file: sudoku.lp