Sudoku solver

Pete Forman petef4+usenet at gmail.com
Thu Mar 26 18:24:24 EDT 2015


Here's my Python sudoku solver which I wrote about 10 years ago.

http://petef.22web.org/sudoku/

It works by applying the solving techniques I came up with. No trial and
error or backtracking is used, so it is not up to cracking the very
hardest puzzles. Run time is 15 ms to 45 ms on a 2009 MacBook Pro using
Python 2.7.9.

There are verbose options to print the steps. Sizes and multiple grids
are flexible. IIRC it took a day or two to adapt the program when the
first samurai was published.

$ python sudoku.py -i sudoku2.sud
***|7**|***
1**|***|***
***|43*|2**
---+---+---
***|***|**6
***|5*9|***
***|***|418
---+---+---
***|*81|***
**2|***|*5*
*4*|***|3**
Solved, rating: dead easy
Calculation took 18.006 ms
264|715|839
137|892|645
598|436|271
---+---+---
423|178|596
816|549|723
759|623|418
---+---+---
375|281|964
982|364|157
641|957|382


-- 
Pete Forman
http://petef.22web.org/payg.html



More information about the Python-list mailing list