Generate sudoku puzzles of varying difficulties.
This is a sudoku generating application. It generates a sudoku puzzle with a unique solution
of varying difficulties according to the requested difficulty. It guarantees that there is always
a single unique solution for the puzzles it generates.
This was one of my projects for a math modeling class in college.
This is not being actively developed, though there are certainly
improvements that could be made.
Yep, lots of sudoku generators exist. Something cool that makes this one unique is
the concept of board density in relation to difficulty. The basic idea is that the
more disjoint the set of starting cells is, the more difficult the puzzle will be
to solve. This goes beyond the normal measure of “less starting cells is more difficult”
and begins to consider what particular configurations of those starting cells makes for
the most difficult puzzle.
python3 sudoku_generator.py base.txt <difficulty>
7 | 9 | 8 | 4 | 2 | ||||
7 | 8 | 6 | 3 | |||||
1 | 4 | 6 | 3 | 7 | 8 | |||
5 | 6 | 4 | 8 | 3 | 1 | |||
8 | 2 | 1 | 5 | 4 | ||||
6 | 4 | 9 | ||||||
3 | 5 | 2 | 7 | |||||
4 | 6 | 8 | 7 | 9 | 1 | |||
7 | 8 | 1 | 3 | 4 | 2 | 6 |
3 | 1 | 6 | ||||||
9 | 6 | 2 | ||||||
4 | 9 | 8 | 3 | |||||
3 | 9 | 8 | 4 | 1 | ||||
7 | 8 | 1 | 5 | |||||
2 | 6 | 5 | 9 | |||||
4 | 6 | 7 | 9 | 8 | ||||
5 | 6 | 9 | 1 | |||||
8 | 7 | 3 | 4 |
2 | 6 | |||||||
1 | 4 | 8 | ||||||
6 | 4 | 3 | ||||||
6 | 7 | 8 | 2 | |||||
1 | 6 | 3 | 8 | |||||
8 | 9 | 5 | 3 | |||||
9 | 4 | 2 | ||||||
2 | 7 | 5 | ||||||
1 | 5 | 4 | 2 | 7 |
7 | 3 | 2 | ||||||
4 | 9 | |||||||
8 | 7 | 3 | 5 | |||||
2 | 5 | 8 | ||||||
7 | 2 | 1 | ||||||
6 | 5 | 9 | 4 | |||||
3 | 1 | |||||||
4 | 6 | 8 | ||||||
5 | 1 | 3 |