It’s pretty straightforward to make a Sudoku solver in Prolog especially when applying CLP (Constraint Logic Programming).

Here is how to use my program:

Then you can enter the known numbers one by one.

When complete, the program determines and prints the solution.

Typing

Gives

By pressing ; over and over again, you could enumerate all 6,670,903,752,021,072,936,960 possible Sudoku solution grids, but this might take a while..

It shouldn’t be too hard to extend this program to actually create new puzzles. If anyone does, let me know.

The prolog environment I used here is SWI-Prolog.


Aswin van Woudenberg

I'm a lecturer at the NHL Stenden University of Applied Sciences where I teach Artificial Intelligence, Algorithms and Concurrent Programming. Together with my students I'm building dialogue systems that can learn, reason and converse in a variety of domains.

Leave a Reply

Your email address will not be published. Required fields are marked *