[pm-h] Sudoku

Paul Archer tigger at io.com
Tue Feb 14 07:12:50 PST 2006


8:19am, Mike Flannigan wrote:

>
> Paul Archer wrote:
>
>> I doubt it would take that long. A human can solve even a hard one in less
>> than 20 minutes. Check out www.websudoku.com to play some.
>>
>> I figure the easiest way to solve a puzzle (from a programmatic point of
>> view) is to mark all the possibilities for each square. Then, for the
>> squares that only have one possibility, mark them as final. Then remove that
>> number from the other squares. Repeat as necessary.
>>
>> Paul
>
> Sounds good.  Then when the square with the lowest possible
> options has 3 numbers, pick one and store the other 2 (all numbers
> for each square) as whole other games to be played after running
> all possible combinations of the current game.  So you are building
> up an array of arrays, each items being another game starting point
> to add to the possibilities of the running game possibilities.  Of
> course each of these other games may spawn other array of arrays
> of future games to play.  I guess you could just append those to
> the primary array of arrays and only have one.
>
> Now if sounds kinda easy.  Just have a printout that prints the
> number of records in the array of arrays and the number of games
> that have been completed to show your progress.
>

The key to this would be to use references.
Let's take the third square down, second from the left, for example.

xxx xxx xxx
xxx xxx xxx
xOx xxx xxx

xxx xxx xxx
xxx xxx xxx
xxx xxx xxx

xxx xxx xxx
xxx xxx xxx
xxx xxx xxx

This square is in the second column, the third row, and the first "meta" 
square. So
$column[1][2]
$row[2][1]
$meta[0][7]
should all be references to the same square.

Once you've got all the relationships squared away (pun intended), then 
solving should be a doddle.


> If I know you Paul, you've already got something going on this.
>

Actually, that's about as much as I've got so far. This is right behind 
finishing the upgrade to my MythTV box (0.19 is out!, plus I've got a new 
HDTV card), and working on the Delcom "VI" light and the libusb stuff.

Paul


More information about the Houston mailing list