Sudoku solver

Some years ago I encountered Sudoku puzzles for the first time, and after working a couple of them by hand, I realized a computer program could do the job much faster. So I wrote a Sudoku solver in C. Why C? Probably because at the time I was doing a lot of work in C, so it was easy to just write one more C program. As it turned out, C is quite satisfactory for this problem.

The basic algorithm is essentially a backtracking process. See the comment at the beginning of the C source file for more details. The algorithm seems to work quite well for 9x9 and 16x16 puzzles. Usually a solution is found in well under a second on a 2.3GHz CPU, although there are a couple of 9x9 puzzles which take 20 seconds (see the README file). A possible future direction for enhancing the algorithm is to use the concept of preemptive sets as described here:

J. F. Crook (2009), A Pencil-and-Paper Algorithm for Solving Sudoku Puzzles, Notices Amer. Math. Soc. 56(4), 460-468.

Follow the directions in the README file at this github repository to compile and run the program on Linux or Windows.

Top Back Home