] Sudoku puzzles

Su Doku or (SuDoku) solver.

I got bored so I wrote a Su Doku solver in Sicstus Prolog. I took about 30 minutes to write it which shows the power of constraint programs. I haven't done any extensive tests but it solved the fiendish problem from April 21st in the Times at the touch of a button. The program should run under gnu prolog with some modification as indicated in the code. Things should run under windows. I have never tried any of this but you have various choices.


Randomly Generated Sudoku

Gives a randomly geneated sudoku. Don't abuse it.

Sudoku solver

Click here for a Solver. Uses Sicstus prolog as a backend.

Sudoku Puzzles?

Ones that might be hard, these all require some non trivial reasoning to complete without back tracking.

_ 7 _ _ _ _ 9 _ _
2 _ _ _ _ 9 _ 5 _
_ _ _ _ 1 _ _ _ 3
_ _ _ _ _ 1 _ 4 6
_ _ 5 _ _ 4 8 _ _
_ 8 _ 6 7 _ _ 2 _
8 _ _ _ 2 _ _ _ _
_ 4 _ 3 _ 8 _ _ 5
_ _ 2 1 _ _ _ 7 _

_ 7 _ _ _ _ 9 _ _
2 _ _ _ _ 9 _ 5 _
_ _ _ _ 1 _ _ _ 3
_ _ _ _ _ 1 _ 4 6
_ _ 5 _ _ 4 8 _ _
_ 8 _ 6 7 _ _ 2 _
8 _ _ _ 2 _ _ _ _
_ 4 _ 3 _ 8 _ _ 5
_ _ 2 1 _ _ _ 7 _

_ _ 5 _ _ 6 _ _ 8
_ _ _ _ _ 4 9 _ 7
1 _ _ 2 _ _ _ _ _
_ _ 3 _ _ 5 8 _ 6
_ _ _ _ _ _ 7 _ _
2 6 _ 1 _ _ 5 _ _
_ 9 _ 8 4 1 _ 5 _
_ _ _ _ _ _ 2 _ _
5 3 _ 6 _ _ _ _ _

_ _ _ _ _ _ _ 4 2
_ _ _ _ 7 _ 9 _ _
_ _ 8 4 _ 6 _ _ 5
_ _ 3 _ 4 _ _ _ 7
_ 5 _ 6 _ _ 8 _ 1
_ _ 6 _ _ _ _ 3 _
_ 6 _ _ 2 _ _ 7 _
8 _ _ _ _ 1 4 _ _
1 _ 4 9 8 _ _ _ _

9 _ _ _ _ _ 7 _ _
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