Wednesday, October 01, 2008

Sudoku

I recently (as in last weekend) became interested in Sudoku and in addition to thoroughly enjoying solving them I found that it is thoroughly annoying to have to manually track which answers remain as possible choices are ruled out when I commit answers to my answer grid. Naturally I wrote a program to handle that tedium for me, which I present to you here: The Sudoku Solver Helper.

Here's what the instructions say:
When solving Sudoku puzzles you need some way of keeping track of
what possible answer values remain as you work your way
through the answer grid. The newspaper puzzles have squares that are too small to write more than a couple of numbers in, and using scratch paper isn't very practical unless you go to the trouble of creating a grid to hold all of your markup.

This seemed like the perfect job for a web application, so I set out
to create a grid I could use to track my guesses and remaining choices as I worked my way through a Sudoku, and what you see here is the result of that effort. To use it you enter your answers in the top grid, and the lower grid automatically removes those values from the row, column, and sub-grid region that the answer is in in the top grid.

A couple of things to note:
  • Puzzles that are easy and medium pretty much solve themselves. As you enter values in the top grid, enough values are eliminated in the lower one to leave only one choice per square. This gets boring fast, and if you don't want to see the answers, either try harder puzzles, or don't use this tool.

  • There is no undo -- if you make a mistake and want to change your value in the top grid you can, but the lower-grid values that were removed already for the mistaken entry will not be restored.

  • As I tested a few different puzzles I thought it would be handy to somehow lock the starter values in the top grid, or at least to be able to know what they were initially by giving them a different background color. That way, if things go wrong and you start shifting things around to get a fit on a tough area you would know which ones should not be changed. I ended up not adding that feature but may do so in the future.

  • There is no code in place to enforce using only digits 1 through 9. I went back and forth on this one and decided that it doesn't really matter what you use as answers in a Sudoku as long as you have only one of each in each row, column, and region. So, use letters or symbols if you like; it doesn't matter (except that the lower grid always holds 1-9 -- sounds like another future feature to allow setting the answer types).
So, it takes the drudgery out of tracking answer choices and is pretty simple to use. If you have any comments or questions, shoot me an e-mail at sudoku@leobartnik.net.

Enjoy!