Back in my introductory programming course in university, which was in the beginning of 2016, one of the major part of the course was called "Something Awesome". Something Awesome is basically choosing to learn a particular skill by doing a project or something. I chose to learn Problem Solving by creating a Sudoku solver, because I enjoy solving Sudoku puzzles, and I thought it would be great to have a program that solves Sudoku puzzles.

At the time, I wasn't even sure that it would be possible to create a program that can solve Sudoku, due to the limited amount of programming and algorithms knowledge I had. However, my tutor for the course encouraged me to do this project and thought this was cool.

Before I actually started coding, I wanted to reread the Sudoku rules and use it to start my program. So the rules was that each number can only appear once in every row, column and region. Hence I made functions that compare the numbers in a row, column or region. I decided to store the puzzle as a 2d array.

I first tried to solve a puzzle by iterating through the array and filling in numbers that are not in the row, column, or the region of the empty box. This worked, but only with puzzles that are very easy to solve. I was not aware of recursion at the time and put my project to rest.

However, after my introduction to data structures and algorithms course, I started thinking about my solver again and thought that maybe I can use something similar to a Depth-First Search to solve my puzzle. So what I did was to use recursion to solve a puzzle, calling the function over and over to solve the next empty box in the puzzle. As a result, if no number can fit in to a box, I would go back to the previous and change the number in that box.

After implementing this, I was pretty happy that my solver can now solve the puzzles I could not solve last year. At this point I am pretty confident that it should be able to solve all valid puzzles. Then I thought that maybe it would be a good experience to make it into a web application. It was not easy but I think it was fun. I learnt how to do a lot of things with django, and maybe one of the most interesting part was to actually read the documentations to help me do things.

Check out my solver here: http://www.bellamangunsong.com/sudoku

See it on Github: https://github.com/bellarm/sudoku