Zorac (zorac) wrote,
Zorac
zorac

Sudoku

Ages ago, I started coding up a perl-based sudoku solver and managed to get it solving lots of puzzles with only a very basic set of rules for solving them. Recently, alnitak (who is also writing a solver, this time in java) showed me a really nasty puzzle which neither of our solvers could completed (although a human could spot the next step). After some discussions we came up with a new solving rule, which I've implemented in my code and now allows me to solve the puzzle.

Anyway, what I'm looking for is some truly evil sudokus to test my solver with, so if you've got any nasty ones that you can send me, that would be much appreciated.

+---+---+---+
|738|.1.|.9.|
|.9.|5..|74.|
|..4|...|...|
+---+---+---+
|64.|28.|3..|
|...|...|...|
|..2|.95|.87|
+---+---+---+
|...|...|1..|
|.87|..2|.3.|
|.5.|.6.|279|
+---+---+---+
Tags: geekery, puzzles
Subscribe

  • 100 Cols Challenge

    I'm not a big fan of strenuous physical activity, but not everyone in my family has such a high level of sanity. For example, my cousin is…

  • I'm still here...

    Ack! A whole week sans internet - the Mardi Gras carnival had everything shut down Monday to Wednesday this week (which also means that the…

  • Je suis en Martinique!

    I was going to post a vaguely long entry, but the AZERTY keyboard in this internet café (which took an hour of wandering around Fort de France to…

  • Post a new comment

    Error

    Comments allowed for friends only

    Anonymous comments are disabled in this journal

    default userpic

    Your reply will be screened

    Your IP address will be recorded 

  • 11 comments
Would it be rude to ask what your rules are? I've not done many sudokus but would be interested in seeing how you'd code up a a solver.
OK, firstly the solver maintains a full set of pencilmarks for each cell, and for each group (row, column or box), and then applies these rules in order:
  1. Look for cells with only one pencilmark in. Put that number in. (This one alone is sufficient to solve the 9x9x9 so-called Dion Cube).
  2. Look for pencilmarks which appear in only one cell of a group. Put the number in that cell (these first two rules solve pretty much all 'Easy' and most 'Medium' difficulty puzzles).
  3. Look for n cells in a group containing exactly the same n pencilmarks. Remove those pencilmarks from all other cells in the group. (Adding this solves most 'Difficult' puzzles).
  4. Look for pairs, triples etc - eg two pencilmarks, both of which appear in exactly the same two cells within a group. Remove all other pencilmarks from those cells. (I'm not sure if this one is actually needed).
  5. Consider intersections - on a standard 9x9 sudoku board, this will be groups of three cells which appear in the same box and row/column. If those three cells are the only ones in a box which contain a give pencilmark, remove that pencilmark from all the other cells in the corresponding row/column, or vice-versa. (This is the one which cracked the really hard puzzle).
That may not be terribly clear, but it's probably the best I can manage without resorting to diagrams and/or psuedo-code.
I understand the first three. I'm a little fuzzy on the other two but I suspect its not worth diagrams and stuff. I have vaguely worked out the first 3 I think. I did have a puzzle I couldn't solve so may have been sufficient. Unfortunately it was just one I had in the paper and I don't have it any more so it doesn't help. Its also possible that I applied rules one to three worse than a computer would. :)

I've certainly found online places that offer different difficulty levels of puzzles. Try for example "Solo" from Simon Tatham's Portable puzzle collection (http://www.chiark.greenend.org.uk/~sgtatham/puzzles/). That allows you to create "unreasonable" difficulty solutions which may be able to tax your puzzle. Its possible you could ask nicely and get the code to generate the puzzles and then connect your two programs up to just run continuous tests to try to solve things it comes up with.

  • 100 Cols Challenge

    I'm not a big fan of strenuous physical activity, but not everyone in my family has such a high level of sanity. For example, my cousin is…

  • I'm still here...

    Ack! A whole week sans internet - the Mardi Gras carnival had everything shut down Monday to Wednesday this week (which also means that the…

  • Je suis en Martinique!

    I was going to post a vaguely long entry, but the AZERTY keyboard in this internet café (which took an hour of wandering around Fort de France to…