You are viewing motris

 
 
31 December 2008 @ 07:36 pm
"Countdown": How to write a themed sudoku  
So I've given a lot of different kinds of puzzles here, and stories about puzzle events and such, but I've never really told a good demonstrative story of how to write a sudoku. I figured this should change, since almost no sites or books in English really demonstrate how the "hand-written" process occurs. I also figured now was the right time to do this, as I had a theme in mind.

Countdown Sudoku!



Why New Year's Eve? Well, the most common solving theme I've seen that I wanted to try to write myself was a "1-9 in order" puzzle, but since 12/31 offered a 9-1 variation I've never seen, I figured sure, why not be the first to do that. Now, most 1-9 puzzles are meant to be solved with just singles, but I want to show you general sudoku writing strategies, so the difficulty of the puzzle may be higher than most 1-9 puzzles, the best path for you may not be going in a 9 to 1 order, but this will demonstrate the concepts I want just fine. At the end, any solver can look at just the digit 9 and place all of those first, then look at the digit 8 and place all of those, .... The final property of solving in order is not a common one for a sudoku to have, and I hope this "Countdown" puzzle will show you the kind of theming that a hand-written puzzle can have in store as you watch me place the digits down in the grid in order too.

The first step, in writing a sudoku, is to choose WHERE givens will go. Not what the givens are, yet, just where. Most "unpatterned" grids should have rotational symmetry. I write a lot of themed puzzles without such symmetry but only when I have a theme in the givens worth doing. Today, I thought a 2009 in a grid made some sense, so I placed some givens, twenty-eight in total, that sort of say 2009. Just making a puzzle with this shape is more themed than most sudoku you will find out there, but its not really the theming I'm talking about in terms of how the puzzle will solve yet. That's what the rest of the lesson will cover.

Choosing where to lay out the pattern takes some experience. To have some interest/difficulty, I left row 5 blank. However, to make the puzzle reasonably easy to construct, I knew to stagger the 0's so that no columns would be left blank as well. I could have had the top zero over one more column to the right and the bottom zero over one more column to the left, but that would leave very few givens in columns 4-6 (only four total) to specify all of those squares. That just won't be easy to do, especially in a 9 to 1 puzzle. So I put the givens as you see them. I think it looks nice even with just the X's. The first picture of this puzzle I have therefore is this:



Now, in my sudoku lecture, I sometimes tell people to keep two copies of the puzzle on the page at one time when constructing - the left side is the "solver's picture" with just the givens, and the right side as the "constructor's picture" with the givens, all deducable numbers from the current state of the givens, and other pinned cells. Its simpler, if you have colored pencils, to probably do it all on one image and I will do it this way here. Everything in black (an X or a number), will be what the solver eventually gets. Everything in color is something else perfectly deducable from just what is in black.

Let's get started. How to place givens? Well, you should look for some spots that can easily force a couple numbers to be placed. Look at R7C8, for example. If R9C4 were a 9, and none of the X's in Box 9 were a 9, then that cell at R7C8 would have to be a nine. This would be a simple hidden single. We can make this happen by placing a single 9.



Now, already knowing there is a 9 in R7C8, we can use it to place another digit in a similar way. Since we set what all the X's are, we can always say "this X is not a 9" and use that to place digits using singles. If R6C9 is a 9, for example, and the X's in R23C7 are not 9's, then R1C7 must be a 9. This is shown below in the light gray cells. With all those set, it takes a little practice to see that a single 9 at R3C2 forces the other 4 9's (in dark gray cells below) provided you still use the "no more X's are 9s" thinking. We started with twenty-eight givens and only needed to specify 3 of them (less than one ninth overall) to get all the 9's in the grid. This is a great start!



Of course, placing digits like this is not always so easy. The 9 going into R7C8 was a really simple place to start because of the geometry of givens I chose. However, no simple spot like this is left. Now we will have to think of pairs of spots as means to place additional instances of numbers. I love pointing pairs, for example, and use them all the time to solve sudoku super fast. I look at the geometry of rows and columns in box 8 and think, oh, if an eight is in R6C4 and R9C9, then I've isolated an 8 to one of the cells in column 6 in box 8 (rows 7 or 8), meaning I could force an eight up in R1C5.



If you really look ahead, you don't even need to add more givens to place a lot more 8's. Let's say I did not place any 8's as givens in column 3. Then R3C3 must be an 8. This makes R2C8 also an 8 (if R2C7 is not an 8). This makes R4C7 also an 8 (assuming none of the X's in R4C123 is an 8). Basically, if you see black X's as not the number you are looking at, you can make a lot of progress in constructing a puzzle. This is the same basic thing you do when solving these puzzles anyway, so hopefully the thinking is familiar.



In this case, where I want to have a 9 to 1 theme to the puzzle, you will see I've painted myself into a corner where I cannot specify the little 8's at all. This is not good here, but also is a potential cause for an invalid sudoku at the end of the process as I might have multiple solutions that still don't specify the 8's. So, while I've only been talking about how specifying givens leads to placements in the puzzle, I should give a more meta-discussion of how to identify the difficult spots of a sudoku construction, where you need to be careful and get digits specified intentionally to help you out in the process. Let's instead go back to before any 8's and consider the cells I've marked in gray. These are the "difficult" spots of this sudoku. The most difficult is row 5, where I currently have no direct "control" on what any digits are or are not. This is in dark grey. However, in starting this puzzle, the areas in columns 12 and 89 in medium gray are also a big concern. I don't have a lot of givens in those columns (only 2-3 total), and I have a good potential for either/or choices for numbers in these columns that cannot be specified. Columns 4 and 6 have a similar problem. There are only 2 givens in each of these columns and a lot of opportunity for, say, the digits 1 and 2 to be in either columns 4/6 in a given row, and to not have a 1 or 2 in the givens in those columns to push the either/or choice in a given way. Being able to sense the "hard" places in a construction is valuable, as you can address potential problems early or avoid them entirely. This same skill of identifying the constrainted/unconstrained spots associated with a particular geometry of givens is tremendously valuable when solving the puzzles too.



So, in placing the 8's, I want to try to fill in these regions as much as possible. Trying to get an 8 into R7C1 is tempting as we've got a 9 into the lower-left already to help out. Notice that putting an 8 at R9C9 as well as either of R1C2 or R4C2 will do this (again, since we won't put an 8 where the X's are in that lower-left box). Putting in a couple more 8's such as R5C3 and R6C4 will specify the location of all the 8's.



I'll put in the 7's now as well, targeting getting a 7 down in R9C1 so that I completely remove that dark grey area from before from being a major concern. The first placements you try may not give you all 7's at once, but there are still a lot of givens to place so try something else. My first shot worked alright here, with four 7's giving all the other 5 in the grid (now in blue).



And I'll put in the 6's - still not taking too many of the black spots, but trying to get all the 6's in. Here, I actually found some spots that led to difficult placements, but that by walking around the whole grid would eventually get all the 6's (in orange) in.



Now, let's assess where we are at. We have a row (8) and a column (3) that are almost done. It turns out, when there is just one cell left in those rows, we have total control already of the digit in that spot. I mark those two cells with a pink X to tell me they are no longer places to be concerned about. It turns out, while I do not know where the three digits in R4C789 go, I know what those digits must be so I can control R4C4 now as well.



It is generally good to start specifically targeting white areas now so this is what I begin to do. For example, with a 5 in R7C9, I can push a 5 into R9C2 and completely specify the cell in R7C2 as well as it is the only white cell left in that spot. I can even use the R3C3 spot (not a given) to put in a 5 that will fully specify where the other 5's go. This gives me more numbers and more cells that are filled with colored X's. You may not immediately recognize how I got all the pink X's in that I did, but in all cases they came from knowing everything else in a row/column in a normal sudoku solving sense to leave a naked single. Pink X's then propagate.



I really want to minimize the white areas now, so with 4, the next digit in this solving path, I would love to get a number in R5C4 (that also goes in R6C2) so the whole middle is specified. One way to do that is to put a 4 in R1C6 (to put a 4 possibly in R9C5) as well as a 4 in R4C8/9. Putting in the 4's carefully to make sure all are specified, I can get my grid here.



Now, almost all cells are in our control and we haven't even considered three of the digits! We have tons of X's in the grid that are still to be specified. I have eight original givens still unspecified, and the rest of the puzzle "effectively" solved except for two pairs of cells in rows 1/3. This is where you want to be at this point, so that you can get to just one solution easily.

To finish, we need to "think" about what the white cells in rows 1/3 mean. Because there is a huge potential for a deadly pattern in those spots, you will realize that you MUST use R3C6 as the same digit as R1C9 (and not R2C9) - hopefully you can see why as you want just one answer. As long as you do that, you can use any of the dozens to hundreds of puzzles that still remain depending on how you lay out the remaining X's (all of these puzzles will be valid sudoku - some may be a bit harder than others). I chose one such set of givens for the remaining X's and completed the puzzle as shown.



Now, this lesson does not cover all the things you will encounter while trying to write a puzzle. You may, even with good "control" over cells, box yourself into a corner where you cannot get ANY solution to work. In this case, back up a couple steps to see how the over-constrained spot can be helped. It is often the case if you choose a pattern with few givens (say twenty to twenty-four), that you might need to add in a completely new given spot like the center cell to actually get the puzzle to work. This is ok as long as your starting grid didn't have a 2009-type constraint where the pattern of givens is immutable. While you may embed a particular solution path for solvers, they may not use what you left them. This puzzle solves perfectly if you focus on just the digit nine, then the digit eight, then seven, then six, ..., then finally one and Happy New Year, you're done in reverse order! Your actual solvers may follow a different path. However, by leaving a specific path, with a specific difficulty of its hardest step (something like a pointing pair here), you are guaranteed a puzzle that is at worst at some level of difficulty. And maybe, just maybe, your solvers will find the trail you left, and sense that some of it was done on purpose, and believe that indeed this was a human-constructed puzzle. If you can achieve that, you've constructed a masterpiece. Maybe someday there will be a "New York Times Crossword" equivalent of sudoku for people to buy, and with some of these steps you too can contribute a themed logic puzzle for general consumption.
Tags:
 
 
 
( 7 comments — Leave a comment )
grandpascorpion on January 1st, 2009 05:58 pm (UTC)
HNY
Nice cap to 2008. Thanks Thomas for the insightful breakdown.
Adam R. Wood: butasanzotmeister on January 2nd, 2009 05:49 pm (UTC)
This is incredible. It's the best "what to do beyond the basics" puzzle-construction guide I've ever seen. - ZM
lunchboylunchboy on January 7th, 2009 10:51 pm (UTC)
I've just started teaching myself how to construct sudoku by hand (for an upcoming book project) and this is incredibly helpful. Thanks!
motrismotris on January 7th, 2009 10:53 pm (UTC)
Is this a "learning by doing" kind of teaching? There aren't a ton of resources I've found out there so I'm curious if you have others to link to.
lunchboylunchboy on January 7th, 2009 11:04 pm (UTC)
Yes, learning by doing. My approach has been to place some givens in a way that (hopefully) leads to some interesting deductions, see what areas of the grid are still unconstrained, and refocus on those areas until I have something solvable and unique. Haven't tried anything themed yet though.
(Anonymous) on December 30th, 2009 05:20 pm (UTC)
Times Square
000491000001080500600573000400060010090050020700040030080030007050020400000000050

Ben Wearn, NYC
motrismotris on December 30th, 2009 05:32 pm (UTC)
Re: Times Square
That's a nice puzzle and thanks for sharing it. Happy New Year.
( 7 comments — Leave a comment )