Sunday 27 December 2009

Sudoku for (S)XEmacs

Once a night, there was no soft girlfriend at the side and I decided to play in some game. Tetris is to fast and active, sokoban is completed long ago and World of Goo heats CPU too much — so I choose sudoku. Opened websudoku.com and started playing. Everything is ok, but that is not under SXEmacs and not available offline. Decided to write sudoku.el to play sudoku under SXEmacs. Skim over the internet and found sudoku.el for (X)Emacs. Downloaded, started and disappointed, looked to the code and got depression. So night was spent rewriting sudoku.el to satisfy my needs, namely:

  • Handy, eye-candy and informative interface
  • Possibility to download sudokus from websudoku.com and menneske.no
  • Possibility to print sudokus
  • Possibility to edit sudokus
  • Possibility to save/load sudokus
  • Pencils for master techniques
  • Easy cells autocompletion, so you solve only hard part of the puzzle

Example

Let's run M-x sudoku RET:

sudoku-mode

Here is a bunch of easy cells, for example R5C5 (where cursor is) and of course we are to lazy to fill them, so let's press a, we will get:

autoinsert

Now is really hard part of the puzzle, but peculiarity for the value 4 is seen, so we get the pencil — p and use Nishio technique, starting from R8C9 cell:

pencil
  1. R8C9 -> 4 (Nishio start)
  2. R2C3 -> 4 (only cell in C3 where 4 can be)
  3. R3C7 -> 4 (only cell in R1 where 4 can be)
  4. No place for 4 in 8th square

So 4 can't be in R8C9. C-u p to cancel the pencil. Now we know that 4 is in R2C9:

won

Nice sudoku. I like it, my son will like it too, so let's print it with P. On the paper it will look like this:

printed

Download

Download from http://lgarc.narod.ru/xemacs/sudoku.el

Send notices, bugreports, fixes to lg AT sxemacs.org

No comments:

Post a Comment