Monday, May 13, 2013

Introduction to Sudoku

What is Sudoku?
Sudoku is a 9x9 grid filled with numbers. Imagine a Sudoku as a Crossword equivalent. Crossword uses letters. Sudoku uses numbers. Here is an example of a Sudoku puzzle:
Source: Wikipedia Sudoku. Digits changed.

How to solve Sudoku?
Sudoku is solved by filling in each blank cell with a number. Initial numbers are given as clues to get you started.

What are the rules?
There is only one rule. Each column, each row, and each block must contain the numbers 1 to 9.
 
Let the Sudoku begin!
With this short introduction, you are ready to begin Sudoku solving. To solve Sudoku effectively, you must have some basic knowledge. The coloured terms are some of the commonly used Sudoku terms you should get familiarized with.

Convention used in Sudoku

Row
A row is a 9x1 grid, which runs horizontally from the leftmost grid to the right. There are 9 rows in a Sudoku, as illustrated in this diagram:

Column
A column is a 1x9 grid, which runs vertically from the topmost grid to the bottom. There are 9 columns in a Sudoku, as illustrated in this diagram:

Block
A block is a 3x3 grid. It is formed by 3 rows and 3 columns. There are 9 blocks in a Sudoku, as shown in this diagram:

Band
A band is a 9x3 grid, formed by 3 blocks horizontally. There are 3 bands, of which:
a) Band 1 is formed by Block 1, Block 2, and Block 3.
b) Band 2 is formed by Block 4, Block 5, and Block 6.
c) Band 3 is formed by Block 7, Block 8, and Block 9.
Next diagram illustrates clearly:

Stack
A stack is a 3x9 grid, formed by 3 blocks vertically. There are 3 stacks, where:
a) Stack 1 is formed by Block 1, Block 4, and Block 7.
b) Stack 2 is formed by Block 2, Block 5, and Block 8.
c) Stack 3 is formed by Block 3, Block 6, and Block 9.
Next diagram illustrates clearly:

Cell
A cell is a 1x1 grid. There are 9 cells horizontally which form a row, and 9 cells vertically which form a column. A total of 81 cells form a Sudoku. Each highlighted grid is a cell, as shown in this diagram:

A cell may contain either a clue, or a solution. A clue is the initial number given in Sudoku. A solution is the correct number that solves Sudoku. A blank cell is a cell which does not contain a clue, or a solution. It is simply, empty.
  
Digit
A digit can be any number from 0 to 9. In Sudoku, only numbers from 1 to 9 are used. Therefore, a digit represents any number from 1 to 9 in Sudoku. Any of the following numbers can be a digit: 1, 2, 3, 4, 5, 6, 7, 8, 9.

Cell Reference
A co-ordinate is used to refer to a particular cell in Sudoku. It is used in this format: cell (column,row) where column refers to a column number, row refers to a row number.
Next diagram illustrates the cell reference for each individual cell:
Using the above diagram as a guide, cell (2,2) refers to a cell in column 2, row 2. Cell (6,6) refers to a cell in column 6, row 6.

A sudoku with 30 clues given. Source: Wikipedia Sudoku, digits changed.
Cell (4,5) refers to a cell in column 4, row 5. It contains digit 9 as a clue.
Cell (8,3) refers to a cell in column 8, row 3. It contains digit 7 as a clue.
Cell (7,2) refers to a cell in column 7, row 2. It is a blank cell.
Cell (2,6) refers to a cell in column 2, row 6. It is also a blank cell.

Test Yourself
Based on Sudoku in diagram above,
a) What is the only clue in Block 3? What is the the cell reference?
b) Which other block contains the only clue? What digit is the clue? What is the cell reference?
c) What is the only clue in Column 3, and Column 7? Which block is the clue placed in?
d) How many blank cells are there in Block 5? Any other blocks contain the same number of blank cells? If yes, name the blocks.
e) Give the cell reference for digit 8 in Block 2, Block 4, and Block 9.
f) Digit 9 appears twice in Stack 1. Which block does each digit 9 placed in?
g) Digit 1 appears twice in Band 3. Which block does each digit 1 placed in?
h) What are the 3 clues in Block 4? How about in Row 3? Now, try in Column 6.
i) Which column contains only 3 blank cells?
j) Name all the blocks which contain only 4 blank cells.
k) How many sets of each same digit appear twice in Band 2? How about Stack 2?

Answers to Test Yourself
Readers are encouraged to not look at the answer before attempting the questions above. This allows readers to test their knowledge in comprehending Sudoku terms very well.
a) Digit 7. Cell (8,3).
b) Block 7. Digit 7. Cell (2,7).
c) Digit 9, and Digit 3. Block 1, and Block 9.
d) 5 blank cells. Yes. Block 2, and Block 8.
e) Cell (5,1), Cell (1,6), and Cell (8,9).
f) Block 1, and Block 4.
g) Block 8, and Block 9.
h) Digit 5, Digit 8, and Digit 9. Digit 1, Digit 7, and Digit 9. Digit 1, Digit 4, and Digit 6.
i) Column 5.
j) Block 1, and Block 9.
k) 3 sets (Digit 4, Digit 7, and Digit 9) in Band 2. 3 sets (Digit 1, Digit 2, and Digit 9) in Stack 2.

The Rule in Sudoku

There is only one rule in Sudoku: each row, each column, and each block must contain all digits 1 to 9. To understand this rule clearly, imagine the following partially filled Sudoku:
Column 5, Row 5, and Block 5 are filled with digits 1 to 9.
Verify that Column 5, Row 5, and Block 5 contains all digits 1 to 9. Good questions to ask yourself:
Are all digits 1 to 9 present in the column, row, or block?
Any digits appear more than once in the column, row, or block?

Let's look at how the rule can be violated. What happens if a row, a column, or a block happens to contain any same digit twice? Look at the next diagram:
An incorrectly filled Sudoku in Column 5, Row 5, and Block 5.
Again, ask these good questions: 
Are all digits 1 to 9 present in the column, row, or block?
Any digits appear more than once in the column, row, or block?

Correct observation reveals that:
a) Column 5, with Digit 3 appearing twice, is missing Digit 1.
b) Row 5, with Digit 1 appearing twice, is missing Digit 2.
c) Block 5, with Digit 2 appearing twice, is missing Digit 1.

Therefore in Sudoku, if you find yourself with any digit appearing twice in a row, a column, or a block, you will immediately realise that your Sudoku has been solved incorrectly. Retrace back to find the correct solution, or redo the whole Sudoku.

Good Sudoku 
A good Sudoku is designed to have only one unique set of Solution. It can be solved fully by logical reasoning, without the need to guess. Even the world's hardest Sudoku, AI Escargot, and Everest, can be solved by logical reasoning alone. Extremely high knowledge of Sudoku solving is required to solve these Sudoku. First things first, you need to learn the basic knowledge of Sudoku solving.