-
-
Notifications
You must be signed in to change notification settings - Fork 22
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
May create sudoku boards with multiple solutions #6
Comments
I think a better way to create puzzles would be to start with a full grid, but instead of randomly removing a certain amount of cells, randomly remove cells one by one until the puzzle is no more uniquely solvable. Then, we could remove between 0 and 100% of the unnecessary cells. I just made a pull request with a way of knowing whether a grid has a unique solution or not. If someone wants to go forward from this, it should not be too hard. By the way, thanks a lot @jeffsieu for your work, it gave me a nice way to generate pdfs of Sudokus of various sizes and difficulty ! |
How do I force it to generate a sudoku with only one solution? With the latest version I can check for multiple solutions, but how can I make it not generate those bad boards at all? |
The algorithm used to create boards goes as follow:
So the short answer is : you can't. What you can do though is to use a quick and dirty approach:
What should be done is to write a function that goes like this:
|
Thanks, I did the quick and dirty. It's fine for now. |
For a sudoku board to be valid, there should be exactly ONE solution to an unsolved board. That means the difficulty parameter (in
float
) could tamper the legitimacy of a sudoku problem.There are quite a lot of solutions for creating sudoku boards with only one solution.
The text was updated successfully, but these errors were encountered: