Senior Software Engineer | Front-End Practitioner | AI/ML Interested | 🎙 Podcaster
I thought it would be interesting to create a react app that uses Peter Norvig’s solver ideas and adds some learning layers to the UI.
Here are some details from the design document that I used to create the app. Let’s start.
The idea was to create a sense of flow in the UI, where users can easily understand how to use it.
There are two main modules of the app:
First, I made a command-line version of the basic JS components and utilities:
Then, I started working on the solver service using JEST for testing.
Later, I implemented the react components for the board, modal, messages and buttons, and then integrated with the solver service using react hooks.
Here’s when things started to get interesting. On one side, the UI learning column helped me understand how the solver was working and how to improve the implementation. But, after I ported Peter Norvig’s algorithm, which uses a backtracking search strategy and solves ALL SUDOKUS, I realized the learning column was useless because in the search of a solution, it created temp steps that were not valid. I needed to change my approach.
I could’ve just removed the learning feature and lived with just a simple solver but instead, I chose to implement other solving strategies that provided the detailed solutions.
I did my research about Sudoku solving strategies, and there were more than 38 options. I was totally hooked. See more here
But all of these strategies come with a caveat: you can work on many lines of code while trying to implement some of these strategies and still not solve all the puzzles. (I learned this the hard way). So, I found a solution:
Creating a react app that uses human solving strategies (for learning purposes and for fun), and only applying Backtracking Search as the last resort.
So now, the app will apply this strategies :
Also, it comes with a prevention for infinity loops and a spinner while it’s solving the puzzle.
if you are a Sudoku fan and want to collaborate, take a look of the github repo. Join me in implementing the other 34 strategies!
The enemies of people who work with ideas are not the people with the opposing ideas. They’re those who want to ban the discussion altogether. -Paul Graham
Create your free account to unlock your custom reading experience.