Back in May 2020 when the pandemic lockdown was in full effect and we were spending our time fixing things around the house and generally cleaning up, we came across a bunch of Sudoku books that we had bought our children when they were young. When I opened them, I was surprised to see that at least a few of the puzzles had been started, but none were completed, with at least a hundred still left blank - we were probably too ambitious as parents when we gave them the books as they were probably too young. My first thought was to recycle the books, but that seemed like a shame as people who put the books together probably spent quite a bit of effort on them. So instead, my wife and I each took a few books and started solving the puzzles.

At first, things were going well, as most puzzles seemed quite easy to solve, but that did not last long. By the time I reached puzzle 80, the puzzles were becoming quite hard to solve without guessing - but guessing seemed like a cheat. For some reason I was under the belief that you should be able to solve these puzzles without any need for guessing, yet no matter how hard I tried, I could not solve some of them. And this is where the quest started to figure out how to solve really hard Sudoku puzzles without guessing.

The journey took me to many Sudoku sites like sudokuwiki.org, which describes 38 strategies to solve Sudoku puzzles and learn-sudoku.com which outlines simple and advanced techniques. But what I really wanted was to learn how to solve these puzzles I had, but with assistance when I got stuck. Although there are sites that will solve the puzzles for you, they do not enable you to learn at your own pace, the way I wanted to.

And that’s when I had the idea of building an app that implements a lot of the advanced Sudoku solving techniques that humans could use and then provides progressive hints to help you get better at seeing the patterns yourself. After playing several Sudoku apps, I decided on a 4-step hint process, which allows you to get just minimal help at first, but then gives you more hints, all the way to performing the step for you.

  • The first step is intended to just point you in the right direction by showing you the cells to look at, in order to figure out what your next step should be. This, I now find, is sufficient most of the time, in providing me with what I need to know what to do. It also helps narrow the scope of where to focus my attention, as the puzzle can be quite complex at times, especially when early on you find yourself stuck.
  • The second step outlines what strategy you can use with the cells that were highlighted in the first step. This step tells you the details of the algorithm to be used and the values involved in the assessment. While there does not seem to be a consensus on what to call these strategies, I used what seemed to be most commonly used names, across several websites.
  • The third step highlights the cells that will be affected by this operation. For example, if you have uncovered a naked single, which is the only value that can be in this cell, it will also show you the other cells which might have pencil marks that are no longer valid and should be removed.
  • The final step applies all the changes to the board for the recommended step. Most of the time you should not use this step and instead perform the changes to the board yourself, to help with the learning of the algorithm.

When I started working on this app I thought it would take me no more than a month to complete it, as the game seemed really simple, but things turned out to be quite differently. As I got further into it, it became clear that Sudoku is a very complex game that only appears to be easy because of it's surprisingly simple rules. The game took more than 6 months to develop and there is still more that I'd like to do..

While developing the solvers and building the puzzle user interface, I noticed that a simple improvement to the puzzle board visualization could significantly speed up the solving of the puzzles during the early stages. So I implemented a grid visualization button which selects between different modes of cells highlighting, when a cell is selected that has a value in it. The 4 modes implemented are:

  • Single Selection - which highlights just the cell you select.
  • Crosshair - which highlights the row and column which intersect the selected cell.
  • Peers - these are the cells which form the Sudoku peer cells for the selected cell. In other words, these are the cells that can only contain one instance of the digit selected and therefore cannot contain it anymore if it’s already in the selected cell.
  • Possible - this is the visualization which shows you where the digit from the selected cell can still be placed on the entire board. This can make it very easy to see if digits can be placed in certain rows, columns or boxes which might only have one place available. The way I now solve most puzzles, is by using this feature and going through all the digits to see if there are any singles I can place and then cycling again though the digits until I can’t find any more singles.

To make this feature even more useful, I added a Setting called Tap to Lock, which changes the user interface dynamic so that tapping a digit on they keypad will lock it. This then highlights on the board all the possible cells where the locked digit can be placed on the board. Also, while the keypad digit is locked, taping on a board cell which does not contain a given digit, will place the value of the locked digit into that cell. This significantly speeds up solving boards or putting in pencil marks. The pencil ON/OFF button toggles the type of value that is placed in the cell - either a digit or a pencil mark/possible value. If you tap on the locked digit on the keypad again, it will remove the lock. Now selecting an empty cell will pop up a keypad menu next to the cell that allows you to quickly enter any value.

There are many other features I built to make the solving of the puzzles fun and less frustrating, like showing pencil marks as a grid or as a list of digits, automatically removing pencil marks when entering a digit, showing you when you make a mistake, full undo/redo capability and bookmarking.

For those really advanced users, I created a feature to allow you to generate puzzles of varying complexities including puzzles which are not solvable by the algorithms implemented in the app. With the twenty algorithms implemented in the app, I have found that it can solve over 92% of puzzles out there. This was based on solving over 50,000 puzzles that were either generated or found on the web. With future releases I hope to improve on that by implementing a few more algorithms, but only if they are practical for a human to do it.

Finally, to help me solve all the hard puzzles in the book, I implemented a feature to design your own puzzle, by entering the values of a puzzle yourself. This screen will validate the puzzle to ensure it’s solvable and will even tell you the complexity of the puzzle once you start it. In a future release I hope to improve this feature substantially by allowing you to take a picture of a puzzle and automatically import it into the game to solve.

I hope you give the game and try and have as much fun with it as I've had building it. Happy puzzle solving!