Sudoku

Mohammed Zaheeruddin Malick
2 min readOct 14, 2019

“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! :)

Sign up to discover human stories that deepen your understanding of the world.

Free

Distraction-free reading. No ads.

Organize your knowledge with lists and highlights.

Tell your story. Find your audience.

Membership

Read member-only stories

Support writers you read most

Earn money for your writing

Listen to audio narrations

Read offline with the Medium app

Mohammed Zaheeruddin Malick
Mohammed Zaheeruddin Malick

Written by Mohammed Zaheeruddin Malick

Tireless Learner | Geek | Father of two budding Women leaders!

No responses yet

Write a response