Sudoku Programming with C teaches you how to write computer programs to solve and generate Sudoku puzzles. This is a practical book that will provide you with everything you need to write your own books of Sudoku Classic and Samurai puzzles. But be after reading it, you'll discover that the puzzles in your local paper are not so challenging after all!
We like Sudokus because they test our capacity to recognize and interpret patterns. But how are the clues generated? Where do those quasi-symmetrical configurations come from? When the author explored the Web to find out, he discovered that there were many sites that explained how to solve Sudokus, but none that told him how create them. He also saw many sites and apps to play Sudoku, but, perhaps not surprising, no indication of how they worked.
So, he had to develop his own applications in order to find out. And, from the very start, he decided that he would publish the code for anyone else to use and perhaps tinker with, but the author wrote it in such a way that also lets readers with limited knowledge of programming techniques understand it. In fact, you could decide to start generating thousands of puzzles almost immediately, and go through the explanations of algorithms and techniques later, a bit at a time. The author chose to write the application in ‘plain old C’ because he wanted to make the code accessible to as many people as possible.
In this book, you will find an explanation of all solving strategies, and the code to implement them. Writing the Solver application was more difficult than writing the Generator, because it required designing and implementing each strategy separately. However, the author wanted to include a solving program capable of listing the strategies necessary to solve any particular puzzle. He also wanted to check whether a puzzle was solvable analytically, without any guessing.
This book includes the full listings of both the Generator and the Solver, and explanations of all C modules, with walk-throughs and examples.
The book is written by a hobbyist, and it does exactly what its title promises: Sudoku Programming. It’s neatly split into two parts: how to solve a Sudoku, and how to generate one. I approached it from an algorithmic angle, and the book served that purpose well.
As a Sudoku solver myself, I usually rely on what’s already on the grid to deduce the missing pieces. But solving it efficiently with a computer is a different mindset altogether. It becomes a matter of eliminating as many candidates as possible from each cell until the solution naturally emerges. Perspective really matters. Humans avoid this approach because of sheer information overload, so we gravitate toward more intuitive deduction.
The book walks through thirteen strategies, ranging from simple to increasingly complex. It starts with the most basic idea, i.e. uniqueness. If a cell has only one candidate, that must be the answer, and that value should be removed from all other cells in the same row, column, and box. On the other end of the spectrum, there are situations where no further pruning is possible, and the only option is trial‑and‑error - full brute force with backtracking. I’ll admit I couldn’t fully grasp every advanced strategy, but the progression was still enlightening.
Another interesting point: to generate a Sudoku, you first need a solver. A chicken‑and‑egg situation. If the puzzle has too few clues, the solution won’t be unique, so you need a validator to check uniqueness. The process starts with a completed grid, then removes clues one by one. If removing a clue leads to multiple solutions (you iterate through each candidate value of that cell and there are more than one time a solution can be found), you put it back. The number of techniques required to solve the resulting puzzle is also a decent indicator of its difficulty for humans; though how complete or reliable that mapping is remains unclear.
Sudoku is ultimately a symbolic game; digits can be replaced with any symbols. This means you can create variants simply by shifting numbers. Some "brilliant" Sudoku setups — like multi‑grid puzzles — are essentially just additional constraints layered on top. I enjoyed this perspective: what looks like coincidence or clever design is often just constraint management disguised as randomness.
The author mentions that he considered using object‑oriented design but chose a procedural style for accessibility. I beg to differ; there were many places where OOP abstractions could have simplified the algorithms. If Python had been popular at the time, it would have been a great language to illustrate his ideas. Still, he put real effort into examples to improve clarity, and his visual representation of Sudoku puzzles is tremendously helpful when debugging your own solver. That said, the code does grow a bit unwieldy, and you can sense his frustration in certain sections. Despite its shortcomings, I genuinely appreciate the effort he put in—from puzzle solver to puzzle setter. The book expanded my algorithmic understanding, and for that, I’m grateful.