Sudoku
“Uniform distribution for all, every row, column, and block!”
The program generates a random NP-complete sudoku puzzle, satisfying constraints using backtracking, in Pythonic Art…
The program also generates a random puzzle from the solution.
python sudoku.py
------------------------------------
| 8 1 2 | 5 6 3 | 4 9 7 |
| 5 6 3 | 4 9 7 | 8 1 2 |
| 4 9 7 | 8 1 2 | 5 6 3 |
------------------------------------
| 1 8 5 | 2 3 6 | 9 7 4 |
| 2 3 6 | 9 7 4 | 1 8 5 |
| 9 7 4 | 1 8 5 | 2 3 6 |
------------------------------------
| 6 2 8 | 3 5 1 | 7 4 9 |
| 3 5 1 | 7 4 9 | 6 2 8 |
| 7 4 9 | 6 2 8 | 3 5 1 |
------------------------------------
------------------------------------
| . . . | . . . | . . . |
| . 6 . | . . 7 | . 1 . |
| 4 . 7 | 8 . . | . 6 . |
------------------------------------
| 1 . . | . 3 . | . 7 4 |
| . . . | 9 7 . | 1 . 5 |
| . . 4 | . . 5 | . . 6 |
------------------------------------
| . . . | . 5 . | 7 . . |
| . . 1 | . 4 . | 6 . 8 |
| 7 4 9 | . 2 . | 3 . . |
------------------------------------

Dedicated to my Chandu for her love of Sudoku! :)