A reasonably fast animated Javascript Sudoku solver

mlahiri cs uic edu (insert 'at' after first word to mail me)
© 2007 Mayank Lahiri, released under the terms of the GNU GPL.

This started out as the result of seeing a "hard" newspaper Sudoku instance which the resident expert had solved in 80 minutes. The challenge was therefore to write a self-contained, simple, reasonably fast Sudoku solver in Javascript in 80 minutes.

OK, so it took about 100 minutes -- but that includes the time to design the damn CSS interface. This is based on a fairly simple constraint satisfaction technique implemented without any Javascript bells and whistles. The entire program is about 200 lines long including the test cases, and is included inside this HTML file. The CSS is also included, so you can save this webpage and load it anytime without accessing the Internet. All the computation is done on your computer. You may occassionally be interrupted by your browser asking if you want to stop the script. Just say no (or "continue"). This is by no means polished, or guaranteed bug-free, but it works well in most cases.

A newer, faster and more polished version can be found here.











Testbed: AMD Athlon 64 x2 2 GHz, WinXP, Firefox 2.0.0.8
About 0 seconds.
Less than 1 second.
About 4 seconds (animated).
About 2 seconds (animated), 1 (not animated).
About 24 seconds (not animated) with 4 Javascript timeout prompts.
About 7 seconds (animated).
Enter your own Sudoku board.


animate (much slower)

Enter numbers or try a test case.