View previous topic :: View next topic |
Author |
Message |
| barcode
| Joined: 02 Nov 2005 | Posts: 7 | : | | Items |
|
Posted: Wed Nov 02, 2005 7:42 pm Post subject: Dancing Links Matrix |
|
|
I'm having trouble working out how to map a given sudoku puzzle to a binary matrix as describe in the Addendum of this document
http://spivey.oriel.ox.ac.uk/mike/comp2005/results.html
Could someone please post either some pseudocode or the top left corner of a binary matrix with puzzle so that I can see an example.
All help appreciated. |
|
Back to top |
|
|
| barcode
| Joined: 02 Nov 2005 | Posts: 7 | : | | Items |
|
Posted: Thu Nov 03, 2005 7:05 pm Post subject: |
|
|
Nobody? |
|
Back to top |
|
|
| dukuso
| Joined: 14 Jul 2005 | Posts: 424 | : | Location: germany | Items |
|
|
Back to top |
|
|
| barcode
| Joined: 02 Nov 2005 | Posts: 7 | : | | Items |
|
Posted: Fri Nov 04, 2005 3:13 pm Post subject: |
|
|
Thanks, hopefully this will give me the mental nudge I need to 'get it'.
Andy |
|
Back to top |
|
|
| barcode
| Joined: 02 Nov 2005 | Posts: 7 | : | | Items |
|
Posted: Fri Nov 04, 2005 3:42 pm Post subject: |
|
|
Right, having looked at the code, it seems that I'm populating my initial matrix right (so the binary matrix that represents the generic constraints of Sudoku), but I'm unsure how to add the contraints represented by a puzzles givens.
My first guess was to not add the rows for possibilities we know cannot be true due to a give. So if we know there is a 1 in row 1 cell 1 then we wouldn't add the 8 rows representing other numbers within the cell. However that doesn't seem to work.
Your code if I'm reading it right has two arrays Ur and Uc which specify rows that cannot be in the solution and eliminates them during the main run. |
|
Back to top |
|
|
| dukuso
| Joined: 14 Jul 2005 | Posts: 424 | : | Location: germany | Items |
|
Posted: Fri Nov 04, 2005 3:56 pm Post subject: |
|
|
yes, it should work.
You might also remove the deleted rows from the adressing
by the columns. |
|
Back to top |
|
|
| barcode
| Joined: 02 Nov 2005 | Posts: 7 | : | | Items |
|
Posted: Fri Nov 04, 2005 4:49 pm Post subject: |
|
|
Yes, I was right all alone, I had accidentally typed an i instead of a j in my code which threw everything out. So it all works now. Highly un-optimised at the moment and the code is a mess but it runs in 80millis which isn't too bad.
Do you mean I should 'cover' the columns? |
|
Back to top |
|
|
|