Ch18_sudoku

# Ch18_sudoku - Chapter 18 Sudoku The remarkably popular...

This preview shows pages 1–4. Sign up to view the full content.

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: Chapter 18 Sudoku The remarkably popular puzzle demonstrates man versus machine, backtraking and recursion, and the mathematics of symmetry. 6 8 4 2 3 4 7 8 7 3 1 4 6 5 5 6 4 2 3 6 8 Figure 18.1. A Sudoku puzzle with especially pleasing symmetry. The clues are shown in blue. You probably already know the rules of Sudoku , but figures 18.1 and 18.2 illustrate them. Figure 18.1 is the initial 9-by-9 grid, with a specified few digits Copyright c 2009 Cleve Moler Matlab R is a registered trademark of The MathWorks, Inc. TM August 10, 2009 1 2 Chapter 18. Sudoku known as the clues . I especially like the symmetry in this example, which is due to Gordon Royle of the University of Western Australia [1]. Figure 18.2 is the final completed grid. Each row, each column, and each major 3-by-3 block, must contain exactly the digits 1 through 9. In contrast to magic squares and other numeric puzzles, no arithmetic is involved. The elements in a Sudoku grid could just as well be nine letters of the alphabet, or any other distinct symbols. 9 6 3 7 8 1 2 4 5 2 1 7 4 5 6 8 9 3 5 8 4 9 2 3 7 1 6 6 5 9 8 4 7 3 2 1 3 7 8 2 1 9 5 6 4 1 4 2 6 3 5 9 7 8 8 2 5 1 9 4 6 3 7 4 9 6 3 7 8 1 5 2 7 3 1 5 6 2 4 8 9 Figure 18.2. The completed puzzle. The digits have been inserted so that each row, each column, and each major 3-by-3 block contains 1 through 9. Sudoku is actually an American invention. It first appeared, with the name Number Place, in the Dell Puzzle Magazine in 1979. The creator was probably Howard Garns, an architect from Indianapolis. A Japanese publisher, Nikoli, took the puzzle to Japan in 1984 and eventually gave it the name Sudoku , which is a kind of kanji acronym for “numbers should be single, unmarried.” The Times of London began publishing the puzzle in the UK in 2004 and it was not long before it spread back to the US and around the world. The fascination with solving Sudoku by hand derives from the discovery and mastery of a myriad of subtle combinations and patterns that provide tips toward the solution. The Web has hundreds of sites describing these patterns, which have names like “hidden quads”, “X-wing” and “squirmbag”. It is not easy to program a computer to duplicate human pattern recognition capabilities. Most Sudoku computer codes take a very different approach, relying on the machine’s almost limitless capacity to carry out brute force trial and error. Our Matlab program, sudoku.m , uses only one pattern, singletons, together with recursive backtracking. To see how our sudoku program works, we can use Shidoku instead of Sudoku . “Shi” is Japanese for “four”. The puzzles, which are almost trivial to solve by 3 1 2 3 4 Figure 18.3. Shidoku 1 2 4 3 4 3 3 4 4 2 1 3 2 4 3 1 1 2 2 1 2 1 3 4 Figure 18.4. Candidates 1 2 4 4 3 3 4 4 2 1 2 4 3 1 1 2 2 1 2 1 3 4 Figure 18.5. Insert singleton 1 2 4 3 3 4 2 1 4 3 1 2 2 1 3 4 Figure 18.6. Solution hand, use a 4-by-4 grid. Figure 18.3 is our first Shidoku puzzle and the next three figures show steps in its solution. In figure 18.4, the possible entries, or candidates,figures show steps in its solution....
View Full Document

## This note was uploaded on 10/11/2011 for the course MTHSC 365 taught by Professor Adams during the Spring '11 term at Clemson.

### Page1 / 11

Ch18_sudoku - Chapter 18 Sudoku The remarkably popular...

This preview shows document pages 1 - 4. Sign up to view the full document.

View Full Document
Ask a homework question - tutors are online