ogarcia / opensudoku

Open Source Sudoku game for Android.
GNU General Public License v3.0
328 stars 144 forks source link

The pre-loaded lists of sudoku are far from consistent in their difficulties #113

Closed leogott closed 2 years ago

leogott commented 3 years ago

Some sudoku in the most difficult list are solveable in minutes, as they seem to only require basic techniques unvolving singles, pairs and triples, while there is at least one in the middle difficulty folder, that is beyond my current abilities (without trial&error)

chrisawad commented 3 years ago

Hi leogott!

This one is an interesting problem. While this isn't related to the stored list of games, I do witness this issue sometimes in the generator I'm working on. If anyone is aware of a good method of scoring generated suduko games by difficulty, I'm all ears.

At the moment I score difficulty based on number of empty cells and that's it.

As far as I know, the games that make it into the paper/magazines are hand selected vs generate and go.

Note: in not the main developer, nor has my code been pushed into the master branch yet - just noticed your comment :).

leogott commented 3 years ago

This one is an interesting problem. While this isn't related to the stored list of games, I do witness this issue sometimes in the generator I'm working on. If anyone is aware of a good method of scoring generated suduko games by difficulty, I'm all ears. […] Note: in not the main developer, nor has my code been pushed into the master branch yet - just noticed your comment :).

I have a few thoughts on that, should I open an issue in your fork to discuss them?

jlnordin commented 3 years ago

I have also noticed this. I'm working on a fork that adds a step-by-step solver that demonstrates the techniques required to solve each puzzle. (One day I'll get a pull request out...)

Until then: Chris - feel free to look at my fork to see the step-by-step solver. One thing it can do is tell you how many different steps each puzzle takes and exactly what techniques are required. This can be used as an accurate way to determine puzzle difficulty.

As part of that work, I determined that Medium puzzle #8 is one of the hardest in OpenSudoku. :-) It appears to require at least some Y-Wing or W-Wing logic in addition to pairs, triples, X-Wings, and swordfish techniques.

rewolff commented 3 years ago

The "difficulty" of a sudoku is difficult to estimate. If you happen to spot some relation that the "difficulty measure" does not take into account, then it can become MUCH easier to solve than the measure would predict.

I wrote a solver once. It looks at each of the rows, columns and squares. If there is only one place to put a number, then place it. That's it. No doubles, triples etc. This solved all the sudokus in my paper, so I stopped there.

Now as a measure of difficulty for this solver you can determine the average number of moves available at each stage of solving. If the average number is, low it is difficult, right?

Consider a sudoku that is difficult according to this measure. But what if the first thing YOU do is spot a double or triplet that eliminates a bunch of options. This could suddenly change the sudoku from "difficult" to "easy".

Similarly an easy sudoku that has just one spot where there is only one or a few moves available, can become difficult for you if you fail to spot that single move.

leogott commented 3 years ago

I played around with it a little bit and used a Sudoku Solver to determine the most difficult human-usable technique required in each of the provided sudokus. The explanation can be found here.

Then I counted the resulting ratings for each category. I arbitrarily decided the upper and lower bounds for each categories and listed the outliers. (See below

https://opensudoku.moire.org/sudoku/easy.opensudoku Easy difficulty is less than 2 Number Difficulty Notes
95x 1.2 (Hidden Single)
5x 1.5 (Hidden Single)

-> easy sudokus are easy

https://opensudoku.moire.org/sudoku/medium.opensudoku Medium difficulty is at least 1.7 and less than 4 Number Difficulty Notes
46x 1.2
45x 1.5
1x 1.7 31
2x 2.0 7, 51
1x 4.0 (Skyscraper 011) 56
1x 4.2 (XY-Wing) 64
2x 5.5 (WXYZ-Wing 126) 14, 69
1x 5.6 (BUG type 1) 78
1x 7.1 (Forcing Chain) 91

-> most medium sudokus are easy. Only 7, 31, 51 are medium.

https://opensudoku.moire.org/sudoku/hard.opensudoku Hard difficulty is at least 3.6 and lower than 5 -> The sudokus 8, 12, 30, 32, 40, 42, 82, 91, 94, 20, 73, 80, 98, 79, 45 are hard difficulty. 63, 7, 68, 5, 55, 34, 14, 88 are very hard. The rest is easy or medium.

https://opensudoku.moire.org/sudoku/very_hard.opensudoku Very Hard difficulty is at least 4.0 -> 3, 20, 28, 32, 34, 36, 42, 52, 55, 57, 62, 65, 67, 72, 79, 84, 91, 95, 98, 100, 1, 2, 7, 11, 12, 17, 18, 21, 23, 26, 30, 35, 37, 43, 44, 47, 49, 50, 56, 60, 64, 66, 68, 74, 77, 78, 80, 81, 83, 85, 90, 97, 6, 10, 53 are too easy.

See this gist for the full list of ratings.

ogarcia commented 2 years ago

I'm migrating Open Sudoku development from GitHub to GitLab. To make the migration as clean as possible I'm going to close this issue. If you are still interested (or if it is still relevant), please open it again in GitLab from July 26.

Thank you very much for your understanding.