Codementor Events

How and why I built Sudoku Solver

Published Nov 17, 2019
How and why I built Sudoku Solver

About me

3rd year Computer science Engineering Student with honors in CSE, a competitive coder on codewars ranked under 20k. Udacity Machine learning Engineer nanodegree holder.

The problem I wanted to solve

Well Sundays newspaper always contained a sudoku problem that was too difficult for me to solve.So i thought why not use my coding skill to get the results I wanted.

What is Sudoku Solver?

I built and sudoku solving algorithm that solved sudoku problems of 9x9 matrix form.

Tech stack

I chose python as the coding language as its easy and since the task was complicated the structure and functional properties of python language were pretty useful for the project.

The process of building Sudoku Solver

The process was pretty intensive first of all i went to the drawing board thinking of how to actually do this i drew a 3x3 matrix and thought how it could be done on this miniature matrix of 3x3.But figuring out the right path was difficult and to get inspiration or an idea as to how to solve this problem I started solving sudoku problems on my own easy to expert level but once I got a hang of them I got back to my project I noted down every technique or idea in the notebook that I always carried with me,I made sure not too look this up on google I wanted to build this thing from scratch on my own.Experimenting day after day lines of code stacking up it took me 15 days to complete the code and the moment correctly filled sudoku matrix was given out well I was on cloud nine.

Challenges I faced

The biggest challenge was the fact that number of possibilities in a 9x9 matrix can go up very quickly making it inefficient and in most of the attempts that was pretty evident when I tried to use recursion the recursion limit exceed the default limit built into the compiler very quickly ,same went with loops generators so the code had to be very efficient or it became a nightmare.Second problem was readability of code sometime after few hours of break i used to get lost in my own code as I was solely focused on developing a solution I ignored the readbility part an that too was a great hinderence .

Key learnings

1)Never turn to google to quickly believe in your skills.
2)Try until you crack it solution is the you just have to grab it.
3)Experiment a lot don't hesitate to experiment in fear of breaking the code.
4)Write a clean and readable code.

Tips and advice

Only advice I can give is don't give up struggle keep hanging in there keep on experimenting you will get it just don't quit early

Final thoughts and next steps

Well that was fun experience ,maybe in future I'll try and build a gui for the code but for now got other things to struggle with!d

Discover and read more posts from Ajit Bhalerao
get started
post commentsBe the first to share your opinion
Show more replies