SUDOKU PLACE ARTICLES > WRITING SUDOKU

How To Write Sudoku

"S","U",...

No, just kidding. This article will explain in some detail the method I use to write sudoku puzzles, along with some background as to how I arrived at this approach, pitfalls to avoid, and so forth.

Exercise 1: Filling in the Blanks

As a first step towards creating sudoku puzzles, try "solving" the following puzzle:

That is, take this grid and try to fill it in like a standard sudoku puzzle -- get all the digits filled in. (Use a pencil, even if you are so confident in your sudoku powers that you normally solve puzzles in pen!)

The approach you will probably find to be easiest is to fill in the digits one at a time. That is, start by putting a "1" into each column, row, and box; then fill in the "2"s, and so forth. You will probably get through the "5"s or so before starting to run into potential problems.

By "potential problems", what I mean is situations where there's only one place left to put a "6" (for instance), but there is already a number in that place. When that happens (and you can almost certainly count on it happening), go ahead and put the "6" (or whatever number you are up to) in that place, and rearrange the numbers you already have. Say the number that you are replacing is a "4", you might end up putting a "4" in the row below the trouble spot, then move the "4" that was already in that row up one, and so forth, until everything is according to the rules again.

Placing the last two numbers ("8" and "9") can generally be done both at the same time, with some more shuffling as a near certain requirement.

When you get it all together, congratulate yourself and go get a chocolate; making a sudoku solution with no clues to work from is a pretty good accomplishment!

Exercise 2: Making a Sudoku Puzzle -- the Handmade Way

Now consider the following blank grid:

Notice that I have "shaded in" a number of cells (30, to be exact -- I figure you should start with a fairly large number for your first attempt). These are to be your "clue" cells.

To fill in the grid, start by picking an unshaded cell to be your first "1". Now, pick out two or three of the shaded cells to be "1"s also which, if everything else besides the clues was blank, would force your first pick to be "1". It is best to try to minimize the number of clue cells you use for this, because you are going to have to repeat the process for a lot of cells.

Now do the same thing, but using a "2". Try to make use of the non-clue cells which are already filled as additional constraints. And after each clue is placed, make sure that any additional cells which are "determined" based on what is already filled in as well!

If you are lucky and clever, you will get to the end of this process with a valid sudoku grid. Recopy the clue cells onto a fresh page and attempt to solve it.

Did it work? If so, congratulations again -- you are now a sudoku author!

Question: Is that how you actually write the puzzles for this site?

Answer: No, of course not. That is far too much work.

The key to writing lots and lots of puzzles, such as you need to do to run a sudoku website, is to automate this process. It is possible, of course, to automate this to the point of "push a button, get a puzzle"; and that is what most "sudoku authors" do. There are lots of people with good computer programming skills who have figured this out.

In between "do it by hand" and "push a button", there is a lot of space for semi-automated methods that keep that "personal touch". All of them, I suspect, start with the same first step:

Step One: Write a sudoku solving computer program

I am not going to explain that step here; that will have to wait for another article...

When Things Go Wrong

You may have already discovered this, but the method I outlined above does not always quite work. The most common problem is to use up all your "clue" cells too early, so that you rely on non-clue cells to determine other non-clue cells. The problem with that is you can end up with "loops" that cause multiple possible solutions. I probably need to add a picture for this; but for example: You might end up with one box with two empty cells (both non-clue) that need to be either "4" or "6". Just below that you have another box with two empty cells (both non-clue), which also need to be either "4" or "6". And the empty cells are in the same two columns.

Now, if you could make the first cell a "4", the other 3 would be determined. Or if you could make the first cell a "6", everything would be determined in the other direction. But there is no way to determine any of those 4 cells. You have a puzzle with 2 possible solutions!

"Loops" can be even more complicated than that, as you might discover. There are two possible ways around it:

  1. Make one of those cells an additional clue
  2. Erase all the cells with those values and at least one other, and attempt to re-mix them.

The problem with the first solution is that you end up with ugly, asymmetrically placed clues. And in the extreme, you end up with a lot more clues than you need, as well.

The second solution, to continue the earlier example, would erase all the "4"s, all the "6"s, and say all the "9"s. Now try to "force" one of your loop cells using the additional open cells. (So in picking the extra value to remove, it helps to think about what positions might help force one of the loop cells.)

Keep at it! Sometimes it takes several iterations before you come up with a valid, single solution sudoku. Sometimes you give up and start over, and that works. Sometimes you just give up. But then, you never achieve the difficult without attempting the impossible.

Good luck!