After looking for some code-to-html converter to post the code of my previous blog, I discovered that I had it just under my nose... Scite, one of my favourite editors, has a nice Export as Html function... All I had to do was add the css part to my template and insert the rest of the text in the post. I also used a div tag with attributes ( div class="alt2" style="border: 1px inset ; margin: 0px; padding: 6px; overflow: auto; width: 640px; height: 498px;") to make the code appear in its own window.
Friday, January 13, 2006
A few months ago, my wife gave me a book with sudoku puzzles. After solving a couple by hand, I decided that it was much more fun to try and write a solver...
My first implementation was a quick hack, the code was brief and ugly with lots of index operations in a bad functional programming style, but it worked well. It used only solution-reduction algorithms, no brute force. As such not all sudoku puzzles could be solved, but the ones that could, were solved pretty fast. Satisfied with my little achievement I soon forgot about it...
Then, recently, I read this article on LinuxJournal. The program in article was unfinished (the third part has still to be published), but the code was much tidier than mine. I took some inspiration to rewrite my solver in a more pythonic way. After that I stumbled on the ASPN recipe, which gave me the idea of adding a brute force solver.
The result is a combination of analytic and brute force solvers that performs 2 or 3 orders of magnitude better than the ASPN code.
Enough talk, here it is:
Posted by Ago at 17:01