| ThemePark
| Joined: 22 Mar 2009 | Posts: 17 | : | | Items |
|
Posted: Thu Nov 26, 2009 11:03 am Post subject: Generating sudokus with additional constraints |
|
|
I want to make a program to create sudokus, but I have additional constraints besides the four used in a normal sudoku. Therefore I was hoping that someone could help me with figuring out what the best way/algorithm for creating these sudokus from scratch is.
For my program, a sudoku is thought of as consisting of 9 boxes, each box containing 9 fields, instead of the usual view of it being a 9x9 grid. I have 6 different box patterns which I want to use, and I want to create sudokus that uses the same box pattern in all 9 boxes.
For each time I run the program, I want to create exactly 6 sudokus, one sudoku for each of the 6 box patterns. Furthermore I want to add the constraint that each of the 6 sudoku grids have 4 neighbours, and each grid shares row 1, row 9, column 1 and column 9 with its neighbours, so that a 5 in r1c1 in a sudoku will yield a 5 in r1c9 of its left neighbour.
Because of this constraint, I would also like to generate sudokus which are like mentioned above, but which also has the entire outer rim filled out, i.e. row 1, row 9, column 1 and column 9. I want to do this to test whether a given sudoku can be solved by the help of solving its 4 neighbours.
So these are my constraints to the sudokus I want to create. The thing is that I can think of a few ways to optimize the creation, but I don't know a fully fledged way of creating them very fast and efficiently.
The optimizations I've been thinking of, are switching the bands of a sudoku so I only need to generate 1 sudoku, and from that I can get 35 different copies. And some of my box patterns will be copies of other patterns but with more givens, so if I have a unique sudoku using one pattern, I know that any sudoku using any box patterns that is an extension of the first pattern, no matter what the extra givens are, will be unique.
For example, a sudoku with a box pattern consisting of givens in all 4 corners and in the middle will be solvable if a sudoku exists with the same givens but only in the four corners of each box.
So I hope that there is someone who is able to help me with this. |
|