Skip to content

Instantly share code, notes, and snippets.

@maveonair
Last active December 15, 2015 04:59
Show Gist options
  • Save maveonair/5205778 to your computer and use it in GitHub Desktop.
Save maveonair/5205778 to your computer and use it in GitHub Desktop.
Solving a mini Sudoku in Prolog
num(1).
num(2).
num(3).
triple(X,Y,Z) :- X=\=Y,X=\=Z,Y=\=Z.
allnumbers(X,Y,Z) :- num(X),num(Y),num(Z).
ct(X,Y,Z) :- allnumbers(X,Y,Z), triple(X,Y,Z).
sudoko(A,B,C,D,E,F,G,H,I) :- ct(A,B,C),ct(D,E,F),ct(G,H,I),ct(A,D,G),ct(B,E,H),ct(C,F,I).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment