I'm an aspiring front end developer. I have been a professional musician but have decided to pursue a fascination in programming. I started off teaching myself Python and most enjoyed recreating classic games like Snake, Tetris and Minesweeper. Then I discovered the excitement of working in React and creating beautiful web apps.
I've always enjoyed a sudoku puzzle, and the logic behind solving one, and ever since learning to code making a sudoku solver was an ambition. After beginning to familiarise myself with Typescript I thought it would be a good first project to build with with a basic HTML / CSS / Typescript stack, and a good chance to test my core programming principles and algorithmic thinking.
I'm using the backtracking approach. Essentially; starting at the beginning of the puzzle, enter a number (starting at 1), check if it is valid with the rest of the puzzle, if it is, move on, if it isn't enter the next number. If you get to a number 9 and it still isn't valid, then move back a square and try the next number in that box.
This is quite an expensive algorithm, because I'm looping over the grid, and the numbers in each square thousands of times.
This is probably the most complex algorithm I have worked on. It was challenging at times but I'm proud of it. That being said, I'm planning to keep working on it to find how and where I can improve the algorithm, which I will then upload as a version 2.
If you'd like to take a look over the source code, visit the GitHub repo here. Or if you'd like to see more of what Sam does or contact him visit his website, here.