- #1
Doom of Doom
- 86
- 0
I was wondering if there was a more efficient way of generating sudoku puzzles.
I already have a method to create puzzles of varying difficulties that goes something like this:
- Randomly generate a completed 9x9 solved sudoku
- Randomly remove some of the numbers from the matrix (as determined by the desired difficulty; more difficult means more are removed)
- Solve the puzzle using a logic method
- If more complex logic is needed to solve the puzzle, assign higher difficulty values
- If the final difficulty value is within the desired range, then the puzzle is good
- Else, start over.
This works, but is there a better way to more efficiently generate sudoku puzzles based on difficulty? I am trying to develop an algorithm that starts with an empty puzzle, then systematically fills in squares. The system in which it fills in squares should be different for varying levels of difficulty.
I already have a method to create puzzles of varying difficulties that goes something like this:
- Randomly generate a completed 9x9 solved sudoku
- Randomly remove some of the numbers from the matrix (as determined by the desired difficulty; more difficult means more are removed)
- Solve the puzzle using a logic method
- If more complex logic is needed to solve the puzzle, assign higher difficulty values
- If the final difficulty value is within the desired range, then the puzzle is good
- Else, start over.
This works, but is there a better way to more efficiently generate sudoku puzzles based on difficulty? I am trying to develop an algorithm that starts with an empty puzzle, then systematically fills in squares. The system in which it fills in squares should be different for varying levels of difficulty.