Efficiently Generating Sudoku Puzzles by Difficulty

  • Thread starter Thread starter Doom of Doom
  • Start date Start date
  • Tags Tags
    Generator Sudoku
Click For Summary

Discussion Overview

The discussion revolves around methods for efficiently generating Sudoku puzzles of varying difficulty levels. Participants explore different approaches to creating puzzles, including starting from a completed grid versus beginning with an empty grid, as well as the complexities involved in ensuring solvability and maintaining difficulty levels.

Discussion Character

  • Exploratory
  • Technical explanation
  • Debate/contested

Main Points Raised

  • One participant describes a method for generating Sudoku puzzles that involves creating a completed grid, removing numbers based on desired difficulty, and evaluating the complexity of the solution process.
  • Another participant suggests an alternative approach of starting with an empty Sudoku grid and adding random numbers while maintaining consistency, followed by the original steps for determining difficulty.
  • A different participant highlights the complexity of Sudoku generation, noting that certain variants (like X-sudoku) introduce additional challenges and that randomly removing numbers may not yield a simple solution.
  • One participant points out that solving a Sudoku puzzle is an NP-Complete problem, suggesting that generating instances of larger Sudoku puzzles could be easier but still not trivial, and recommends looking for existing libraries or code examples online.

Areas of Agreement / Disagreement

Participants express differing views on the efficiency and feasibility of various Sudoku generation methods. There is no consensus on the best approach, and the discussion remains unresolved regarding the optimal strategy for generating puzzles of varying difficulty.

Contextual Notes

Participants mention complexities related to the number of filled cells required for solvability and the impact of advanced solving techniques on puzzle difficulty. The discussion acknowledges the challenges inherent in generating Sudoku puzzles, particularly with respect to maintaining a single solution.

Doom of Doom
Messages
85
Reaction score
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.
 
Technology news on Phys.org
Seems like your first two steps could be replaced with these:

- Start with an empty Sudoku
- Add a few random numbers in such a way that keeps it consistent

The rest of the steps could then be followed as given.

- Warren
 
You may underestimate the complexity of sudoku a bit.

Sure, it's simple to generate the solution, albeit there are many sudokus with higher complexity like X-soduku, disjoint group sudokus and disjoint group X-sudokus. That's much more fun.

But generating algoritms for the puzzle from that is not that simple. Certainly not at random. There are redundant numbers and key numbers. If you delete numbers at random you may have to stop at ~30 - 35 filled cells remaining to have a simple solution in basic soduku whereas selecting only key numbers this may reduce to some 22 filled cells. if you allow the higher solution techniques, like hidden and naked pairs (waiting for jesters) the number of filled cells may drop to 17-18 for the very advanced and still have a single solution.
 
Finding a solution to a given variable sized sudoku is actually an NP-Complete problem so it's one of those computer-intractable problems.

Generating an instance of a k*k sudoku should be much much easier (not to say that it's easy or immediately obvious). You should be able to find libraries or code examples for generating sudoku games on the internet.
 

Similar threads

  • · Replies 37 ·
2
Replies
37
Views
5K
Replies
25
Views
4K
  • · Replies 7 ·
Replies
7
Views
13K
  • · Replies 6 ·
Replies
6
Views
3K
  • · Replies 2 ·
Replies
2
Views
2K
Replies
67
Views
8K
Replies
19
Views
2K
Replies
1
Views
3K
  • · Replies 4 ·
Replies
4
Views
2K
Replies
29
Views
6K