Re: Speed Up Sudoku Solver



On 17 Apr 2006 13:47:20 -0700, "Geoffrey Summerhayes"
<sumrnot@xxxxxxxxxxx> wrote:

Andrew wrote:
I have cobbled together a Sudoku solver in Prolog (see below).
However, it is extremely slow (almost a minute with only 8 squares missing!)
as it only uses a backtracking method to solve it.

Get B-Prolog and go to clp(FD) examples. Constraint-based algorithm
presented there is really fast. Translated to SICStus, solves the
following problem in about 10 sec.

[1,_,_,_,_,_,_,_,_],
[_,_,2,7,4,_,_,_,_],
[_,_,_,5,_,_,_,_,4],
[_,3,_,_,_,_,_,_,_],
[7,5,_,_,_,_,_,_,_],
[_,_,_,_,_,9,6,_,_],
[_,4,_,_,_,6,_,_,_],
[_,_,_,_,_,_,_,7,1],
[_,_,_,_,_,1,_,3,_]

A.L.
.



Relevant Pages