Python Object Based Sudoku Solver

GITHUB: code here

Recently I have been spending most of my time trying to learn C and work on the 8-bit computer, and I realised the other day that I had not actually done any proper Python in over a month. Python was the first language I learnt and to this day is probably still my favourite due to its readability and wide selections of libraries. Therefore I set myself the challenge to build a Sudoku solver during my lunch breaks.

I absolutely love object orientated programming, and I’ve been doing a lot of C recently, I wanted to make this object oriented as possible. Here my plan:

I am going to make each level of the grid an object. There will be cell objects. This will be for one cell in the grid and will store the possible values it could be and which it can’t be. There will be one object for rows, columns and boxes which will have their cell objects inside. These all actually share the same properties, they should have values from 1 to 9. They will have all their cell objects inside so they can change them and see where they should be positioned. All of these will be stored inside a large grid object, which will contain all the solving methods.

Sudoku Solver V1:

Aim: being able to solve easy level Sodukus.

The first Sudoku solver was pretty simple. The cells, rows, columns and boxes are created and then the cells are updated with what possible numbers they could be depending on their row, column and box. If there is only one possible number it could be it update the value of the cell to that number.

Before
After

The problem is that this only work for Sudokus in which every step has a cell which only has one possible answer using this method. I am currently working to update the algorithm so that it can beat this. Will be updating soon!

Leave a Reply

Your email address will not be published. Required fields are marked *