DEV Community


Creating a Sudoku Solver and Generator with Python

1blademaster profile image 1Blademaster ・1 min read


I recently created a 3-part tutorial on medium on how to create a sudoku engine which was capable of solving and generating sudoku's. A sudoku which has been generated can also be saved as a string, this makes it easier for the exportation of sudoku's. Bear in mind that the algorithms I show you in the tutorial are very greedy since a lot of recursion is used. Here is a link to the Github repo as well if you wanted to browse through the code.

Since this is a 3-part series, I've added links to all the 3 parts below:

  1. Introduction and creation of the solver
  2. Starting the generator 1
  3. Finishing the generator 2

Example Usage

You can use the tutorial to create a Board class which can further be imported into any of your scripts/programs as shown:

Final Thoughts

If you have any suggestions, advice or questions then please feel free to leave a comment and I shall answer everything.

Thank you for reading! 💖

Discussion (0)

Editor guide