One of the more fascinating areas of modern computing is that of parallel and concurrent (PAC) computing. Of course it has only been in the last couple of years that I’ve had access to the equipment and environment in which to play. However apart from the obvious droll exercises there was still the lack of a suitable fodder to use for demonstrating anything more than a contrived task.
So along came Sudoku. Its a perfect example of a problem set that can be broken down in multiple ways. More than that it is really simple and also flexible enough to investigate the intricacies of PAC. Naturally it is a very small problem. Most often the basic game takes place within an 81 (9×9) cell square board. However it can be scaled up to any square number of cells. So its a scalable problem too.
Now at this point the place to start is with the analysis of the game itself. So for the rest of this article a simple method for solving trivial Sudoku puzzles will be developed. For this series of articles only simple puzzles will be used to simplify the code used to investigate PAC.
Introducing the Game
Sudoku is played on a on a board made up of a grid of cells that can contain a number from 1 to 9. For this example we will limit it to 9×9 or 81 cells but it is possible to scale up. Logically then the board is also composed of 9 non overlapping squares of 3×3 cells each. An empty board looks something like the following.
Starting with a set of known values in specific cells determine the values in the remaining cells currently of unknown value. There are only two real rules:
- A number can only appear once in any given row or column, and,
- A number can only appear once in any given square.
Given these rules the empty grid has the following possibilities:
Which is all very simple. Actually, as with many number games and puzzles, the whole puzzle is very simple. Where it becomes a game is when it taxes the discipline and observation of the puzzler. To assist with terminology as we get nested items there are three terms that I will attempt to be consistent with:
- Board shall mean the whole 9×9 board,
- Square shall mean a 3×3 square within the board, and
- Cell shall mean the smallest part of the board which can only contain a single value.
Puzzle Play
So the first thing that is provided is a grid with a number of values already provided on it.
Which we use to set the known cells in our grid of possibilities.
Now for each value we can remove all of the same possibilities in the square that it sits in excluding the known cell. Observe that for each cell of a square where the ultimate value is yet to be determined they all have the same set of possibilities within that square. This is not important for this article but may be referenced in a future article.
Next for each known value we can remove all of the same possibilities in the row and column that the known cell is in except of course for the known cell itself.
At this point a quick review of the possibilities reveals that there are some:
- Squares where a possibility only occurs in one cell, and
- Cells that only have one possibility.
This means that those are the know values for those cells and the process can start again: setting the cells, clearing the possibility from the squares, and clearing the possibility from the lines. In the example this means that the following cells are now known (shown in yellowish).
Repeating the steps to reduce the possibilities in the the possibility grid we get the following.
If you look closely at the grid of possibilities while you apply the reduction rules you will see that more values become known before you have completely applied the reduction steps. For example I observed the 5 in the centre bottom square before completing the reduction steps.
While these revelations are distracting, enticing the observer to pursue the new value, it is important to note that if you apply the steps sequentially looping through them all of these will be picked up in time. The reason that this is important is to demonstrate that this whole process of reduction can be performed sequentially in a single threaded fashion before investigating the use of a PAC approach.
Closing the Loop
In time the loop will naturally halt because either all of the values have been discovered or because no further single values are found in an iteration of the reduction loop. Because the identifying logic is very simple this will only satisfy very basic Sudoku puzzles. It could be simply extended to include more complicated cases but for our example this would potentially introduce obscuring factors to the overall purpose for this investigation, which is to explore PAC.
For our example used in this post the loop eventually discovers all of the known values as shown in the probability grid.
Giving us the completed puzzle.
Next Time
In this article we simply looked at the mechanics of solving a simple Sudoku puzzle. It gave us the basic procedure for solving the puzzle:
- Identify values,
- Reduce possibilities,
- Loop until no new values are found in one iteration.
Also presented was the idea of using a possibilities table for the reduction process. This will become important in helping keep all of the PAC threads singing from the same hymn sheet.
In the next article we will look at presenting the basic data structures and getting a single threaded, non-PAC, version of this process up and running. With any luck it should prove my hand work above!









