CHAPTER 15

image

Generating Sudokus

To generate a valid Sudoku puzzle you have to go through the following two steps: generate a completed Sudoku and remove numbers from it in such a way that only one solution is possible with the clues that are left.

It sounds easy, but it isn’t—especially the part involved in checking that the solution is unique.

The Sudoku generator I am going to describe to you is the fourth I have written. The first three generators were more cumbersome, used the strategies I developed for the Solver, and were seriously affected by some damning bad choices of mine.

Generating a Solved Sudoku

When I started working on the Generator, ...

Get Sudoku Programming with C now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.