Solving Sudoku with Prolog (2016)
Video:
For example, using CLP(ℤ) constraints, a
valid Sudoku board can be concisely expressed like this:sudoku(Rows) :-
length(Rows, 9),
maplist(same_length(Rows), Rows),
append(Rows, Vs), Vs ins 1. blocks([N1,N2,N3|Ns1], [N4,N5,N6|Ns2], [N7,N8,N9|Ns3]) :-
blocks(Ns1, Ns2, Ns3). Source fileProlog source file: sudoku.pl
The source file contains:
the Prolog formulation of Sudoku puzzles which is shown above
PostScript instructions for
showing animations of
the search processsample Sudoku instances, available is problem/2.
Source: www.metalevel.at