There are 288 different 4 x 4 grids that represent a valid Sudoko solution. But how many partial grids are there that represent a fair Sudoku problem? (By "fair" I mean "give enough information to resolve to a unique solution".)
Here's an example of a fair problem with 4 digits given, and the unique solution it leads to:
+--+--+ +--+--+ | 4| 2| |14|32| | | 1| |32|41| +--+--+ gives +--+--+ | | | |41|23| | 3| | |23|14| +--+--+ +--+--+
The challenge (part 1): code to construct a list or array of the 288 solutions as 16-byte strings of the digits 1234. (E.g. the solution above would be "1432324141232314".)
The challenge (part 2): a program that takes a single integer argument from 0 to 16, and outputs to stdout the number of fair partial grids there are with that many digits given. You may optionally output a newline as well.
Now this represents a fixed 17-term sequence, and the intention is that entries should calculate the terms rather than simply embed them, but I don't know how to specify my intention as an unambiguous rule. So I'll specify this instead: if you don't construct the array from part 1 as part of your solution to part 2, you must specify what knowledge about the problem you took as given, and you'll be competing against people that used the same knowledge.
I wrote some code to help you verify that your program is producing the right* answers, but it's been raining here which unfortunately smudged some of the digits:
perl -MDigest::MD5=md5_hex -wle 'print $s=join",",map`my_entry $_`,0.. +16; print md5_hex($s)' 0,0,0,################################################################ +######################8,288 59344163bcacc12056163949869a84b0
Update 1: lines should not exceed 80 characters.
Update 2: strike update 1; add ref to definition of Sudoku.
Hugo
*"The same answers as I get." Bonus marks for proving me wrong. :)
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: a couple of rounds of golf for the weekend
by hv (Prior) on Aug 19, 2005 at 19:27 UTC | |
|
Re: a couple of rounds of golf for the weekend
by Anonymous Monk on Aug 21, 2005 at 10:24 UTC | |
by hv (Prior) on Aug 21, 2005 at 11:01 UTC | |
|
Re: a couple of rounds of golf for the weekend
by barrachois (Pilgrim) on Aug 26, 2005 at 23:02 UTC |