View previous topic :: View next topic |
Author |
Message |
| owen
| Joined: 12 Aug 2005 | Posts: 1 | : | | Items |
|
Posted: Fri Aug 12, 2005 9:20 am Post subject: [Newbie]Pseudo Code to create a full grid 9x9 |
|
|
Hi,
I'm searching the pseudocode to create a full filled grid 9x9 of puzzle sudoku.
Can you help me ?
Thanks |
|
Back to top |
|
|
| droid42
| Joined: 29 Jul 2005 | Posts: 20 | : | | Items |
|
Posted: Fri Aug 12, 2005 9:45 am Post subject: |
|
|
I'm sure there are much better and faster ways but the following generates a full grid in less than 100ms depending on PC speed...
1. Start with an empty grid
2. Fill in 27 random values in random positions
3. Try to solve (simple logic usually suffices)
4. If the solver hits a dead-end or become inconsistent, go back to 1.
That's it.
A much quicker method is to start with a known full grid and then perform various transformations on it (e.g. swap rows/columns within the confines of a box, rotate the whole grid etc.) but this results in very "samey" groups of numbers and is probably of little value...
Ian. |
|
Back to top |
|
|
|