Last active
December 15, 2015 04:59
-
-
Save maveonair/5205778 to your computer and use it in GitHub Desktop.
Solving a mini Sudoku in Prolog
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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