(Inspired by Re: Subroutine overhead in Perl)
My criteria for good software:
Challenge: Golf a sudoku solver. Bonus points to fast solutions as well. Correct solutions must provide all solutions to a given starting position (test data provided below).
If you want, you can use any/all of the following infrastructure:
- @grid - starts with the initial position (with 0's for empty squares).
- %search - contains 81 entries, indexed by 0-80, each pointing to an arrayref of 21 entries. These entries are squares that cannot contain the same value as the key.
- sudoku_print() - a method that prints the sudoku board as listed in @grid.
- Assume that the input has already been parsed into @grid.
I'll post my solutions in a response to this post.
Some samples are:
-,-,4,-,-,2,-,-,3 -,2,-,-,9,-,7,1,5 7,-,-,3,1,-,4,-,- -,1,-,-,-,-,2,-,9 -,4,-,2,7,-,-,-,6 2,8,-,5,-,-,-,-,- 5,-,-,-,-,3,6,-,4 -,3,1,-,-,8,-,-,2 4,6,-,-,5,-,-,3,1 -,-,5,-,-,-,-,4,- -,-,-,8,-,-,-,-,6 3,-,2,-,-,1,-,-,- -,-,-,-,-,4,-,2,- -,-,9,-,-,-,5,-,- -,6,-,3,-,-,-,-,- -,-,-,-,-,-,-,-,3 -,-,-,-,-,5,-,-,- -,1,-,-,-,-,6,8,- -,-,-,-,-,-,-,-,- -,-,-,-,-,3,-,8,5 -,-,1,-,2,-,-,-,- -,-,-,5,-,7,-,-,- -,-,4,-,-,-,1,-,- -,9,-,-,-,-,-,-,- 5,-,-,-,-,-,-,7,3 -,-,2,-,1,-,-,-,- -,-,-,-,4,-,-,-,9 (This input has two solutions. Both are required to be correct.) 9,-,6,-,7,-,4,-,3 -,-,-,4,-,-,2,-,- -,7,-,-,2,3,-,1,- 5,-,-,-,-,-,1,-,- -,4,-,2,-,8,-,6,- -,-,3,-,-,-,-,-,5 -,3,-,7,-,-,-,5,- -,-,7,-,-,5,-,-,- 4,-,5,-,1,-,7,-,8
My criteria for good software:
- Does it work?
- Can someone else come in, make a change, and be reasonably certain no bugs were introduced?
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: Golf: Sudoku solving
by eyepopslikeamosquito (Archbishop) on Nov 08, 2007 at 21:46 UTC | |
by brx (Pilgrim) on Jan 11, 2013 at 08:53 UTC | |
by BrowserUk (Patriarch) on Jan 11, 2013 at 09:17 UTC | |
by tobyink (Canon) on Jan 11, 2013 at 09:44 UTC | |
by BrowserUk (Patriarch) on Jan 11, 2013 at 09:54 UTC | |
by eyepopslikeamosquito (Archbishop) on Jan 11, 2013 at 09:51 UTC | |
Re: Golf: Sudoku solving
by oxone (Friar) on Nov 08, 2007 at 17:33 UTC | |
Re: Golf: Sudoku solving
by lidden (Curate) on Nov 08, 2007 at 20:17 UTC | |
by erroneousBollock (Curate) on Nov 12, 2007 at 03:40 UTC | |
by tye (Sage) on Nov 12, 2007 at 04:20 UTC | |
Re: Golf: Sudoku solving
by downer (Monk) on Nov 08, 2007 at 17:23 UTC | |
by kyle (Abbot) on Nov 08, 2007 at 17:35 UTC | |
by sg (Pilgrim) on Nov 12, 2007 at 02:50 UTC |
Back to
Meditations