Sudoku Series

Sudoku Series: Implementing Wing Rules
Sudoku Series: Implementing Wing Rules

The next rules to implement for the Sudoku solver are called wing rules. There are a few of these rules used in solving Sudoku, but some are hard to identify and are for very advanced solves. The two needed to solve most Sudoku puzzles are called XY-Wing and XYZ-Wing:

  • XY-Wing uses a pivot cell with …

Sudoku Series: Implementing the Fish Rules
Sudoku Series: Implementing the Fish Rules

The next rules to implement for the Sudoku solver are called the fish rules. There are three versions of these rules but they all share the same principles:

  • X-Wing works with a 2x2 fish pattern.
  • Swordfish works with a 3x3 fish pattern.
  • Jellyfish works with a 4x4 fish pattern.

If you like this post …

Sudoku Series: Implementing the Locked Candidates Rule
Sudoku Series: Implementing the Locked Candidates Rule

Up until now in the Sudoku Series we’ve implemented a number of rules for Sudoku solving. I had been trying to remember the name of an old iPhone Sudoku app I used to enjoy. The reason I wanted to find it was that it used to be good at reviewing a puzzle and telling you what the next logical …

Sudoku Series: Implementing Hidden Set Rules
Sudoku Series: Implementing Hidden Set Rules

In the last Sudoku Series blog post we implemented the naked pair and the naked triple rules. In this post, we will look at implementing the hidden single, hidden pair and hidden triple rules. Applying these rules is documented on many websites, but the two I’ve liked during my research are …

Sudoku Series: Implementing Naked Set Rules
Sudoku Series: Implementing Naked Set Rules

In the last Sudoku Series blog post we implemented the single candidate rule. In this post, we will look at implementing both the naked pair rule and the naked triple rule. These are documented alongside more advanced rules on a Mastering Sudoku website.

If you like this post and you’d like to …

Sudoku Series: Implementing the Single Candidate Rule
Sudoku Series: Implementing the Single Candidate Rule

This week, we hit a major milestone: our solver can now complete very easy Sudoku puzzles, thanks to the simplest rule of all — the single candidate rule. By writing code that parses the grid repeatedly and looks for opportunities to apply this rule, we’re able to solve some of the simplest …

Sudoku Series: Locating Your Neighbours
Sudoku Series: Locating Your Neighbours

When solving Sudoku puzzles, a lot of the logic is about spotting patterns among groups of cells. In this context, a group of cells are those which must not contain a number among them more than once. Let’s build some logic to pick out groups of cells we might want to work with in our solving …

Migrating from Poetry to UV in a Python Project
Migrating from Poetry to UV in a Python Project

This is a very short post about our move from Poetry to UV in the Sudoku Solver we’re building in Python. I don’t have a definitive reason for switching, but I’ve been experimenting with UV recently and I’m starting to prefer it over Poetry. In this post, we’ll outline the goals of the …

Unit Testing Our Python Sudoku Solver
Unit Testing Our Python Sudoku Solver

This week we have a new topic for this blog, which is Unit Testing. While not as exciting as actually writing the functional code for a project, it is an important skill to have. By writing tests for your code, you get to check that it behaves the way you intended. Not only does this let you fix the …

First week implementing the Python Sudoku solver
First week implementing the Python Sudoku solver

This is the update post, a week after planning to build a Sudoku puzzle solver in Python. In this post, we’ll review the direction the project is going and discuss the setup steps involved in this new project.

If you like this post and you’d like to know more about how to plan and write …

Planning a Sudoku solver in Python
Planning a Sudoku solver in Python

Sudoku is one of those puzzles that captivates anyone who attempts to solve it. Sudoku puzzles can range from very easy to fiendishly difficult, despite the rules being relatively simple and unchanging.

To be valid, a Sudoku puzzle must have only a single solution — and this constraint actually …