Saturday, August 20, 2011

Hint for sudoku

I keep playing sudoku at http://www.websudoku.com Most of the time I solve the puzzle easily. There are situation where it is difficult to make any logical move. We get stuck without able to post numbers in any of the cells.

In such cases, I usually fill all the empty cells with the probable numbers that can fit in that cell. For eg, I place the numbers 278 if these three numbers have a chance of being placed in a cell. With all empty cells having such probable numbers, it is easy to apply some deduction logic to narrow down the correct numbers.

Filling in the probable numbers is a tedious task. I came up with a simple java code that would help in filling the numbers (just the hint, not the actual answers).

Instruction to use the code:
  • Install watij as mentioned at http://watij.com/webspec-api/
  • Copy the java code I had placed in the comment section (placed in 3 comments due to comment size restriction)
  • run the java code along with the classpath pointing to watij class and jars
  • This will open a window and websudoku site is opened
  • Settings page is accessed automatically and few settings are tweaked
  • once you get the puzzle page, play it as you would do in normal manner
  • When you get stuck, click on the 'Done' button in the top panel. The button name is marked as 'pauseUntil'
  • we should have numbers filled now. Once that happens, continue with the game

Happy sudoku.