Seed7 - The extensible programming language
Seed7 FAQ Manual Screenshots Examples Libraries Algorithms Download Links
Screenshots Panic Mandelbr Planets Comanche Calc7 Savehd7 Compiler Dnafight Sudoku Wator Tar7 Sydir7 Ftp7 Castle Tetris Make7 Ftpserv Basic Pairs Shisen Eliza Toutf8 Lander Wiz Startrek Mahjong
Screenshots
Sudoku Source Code
 previous   up   next 

Sudoku is a puzzle in which the blank cells must be filled such that each row, column and 3x3 box contains the numbers 1 to 9. The Sudoku7 program helps solving Sudoku puzzles.

Sudoku solving strategies

When solving a Sudoku it is helpful to maintain a list of possible values or candidates for each blank cell. Maintaining the candidates by hand is a boring and error-prone task. Luckily the Sudoku7 program helps by automatically maintaining candidates. In Sudoku7 it is also possible to mark cells according to a specific candidate or according to the number of candidates.

There are several strategies which help to determine the value of cells or allow to reduce the number of candidates. This solving strategies have the following names: singles, hidden singles, locked candidates, naked pairs, naked triples, naked quads, hidden pairs, hidden triples, hidden quads, x-wing and swordfish. The logic of the solving strategies is described below. Sudoku7 can also apply the solving strategies automatically.

Singles

When a cell has only one candidate the value can safely be assigned.

Hidden singles

A candidate of a cell is a hidden single when no other cell in that row, column or 3x3 box contains this candidate. The cell containing the hidden single may also have other candidates, which can be ignored and the hidden single can safely be assigned.

Locked candidates

Sometimes a candidate within a 3x3 box is restricted to one row or column. In this case one of the restricted cells must contain the specific candidate. Therefore the candidate can safely be excluded from all cells in that row or column outside the 3x3 box.

Sometimes a candidate within a row or column is restricted to one 3x3 box. In this case one of the restricted cells must contain the specific candidate. Therefore the candidate can safely be excluded from all cells in that 3x3 box outside the row or column.

Naked pairs

A naked pair consists of two cells in a row, column or 3x3 box which contain an identical pair of candidates and no other candidates. In this case the two candidate values must be in the two cells. Therefore the two candidates can be excluded from the other cells in that row, column or 3x3 box.

Naked triples

A naked triple consists of three cells in a row, column or 3x3 box which contain no candidates other than the same three candidates. It is not necessary that all three cells contain all three candidates of the triple. In the case of a naked triple the three candidate values must be in the three cells. Therefore the three candidates can be excluded from the other cells in that row, column or 3x3 box.

Naked quads

A naked quad consists of four cells in a row, column or 3x3 box which contain no candidates other than the same four candidates. It is not necessary that all four cells contain all four candidates of the quad. In the case of a naked quad the four candidate values must be in the four cells. Therefore the four candidates can be excluded from the other cells in that row, column or 3x3 box.

Hidden pairs

A hidden pair is defined by two candidates which are restricted to two cells in a row, column or 3x3 box (no other cell in that row, column or 3x3 box contains one of the two candidates). In this case the two candidate values must be in the two cells. Therefore the other candidates in the two cells can be excluded.

Hidden triples

A hidden triple is defined by three candidates which are restricted to three cells in a row, column or 3x3 box (no other cell in that row, column or 3x3 box contains one of the three candidates). In this case the three candidate values must be in the three cells. Therefore the other candidates in the three cells can be excluded.

Hidden quads

A hidden quad is defined by four candidates which are restricted to four cells in a row, column or 3x3 box (no other cell in that row, column or 3x3 box contains one of the four candidates). In this case the four candidate values must be in the four cells. Therefore the other candidates in the four cells can be excluded.

X-Wing

Sometimes there are two rows and two columns and the same candidate is present at the four crossings between the rows and columns. When the rest of the two rows or the rest of the two columns does not contain the specific candidate the constellation is called x-wing. In an x-wing the candidates must be in the diagonally opposite corners of the rectangle formed by the four crossings. Therefore the specific candidate can be excluded from all cells in the two rows and in the two columns, except for the four corners of the x-wing.

Swordfish

Sometimes there are three rows and three columns and the same candidate is present at some of the nine crossings between the rows and columns. When the rest of the three rows or the rest of the three columns does not contain the specific candidate the constellation is called swordfish. In a swordfish the candidates must be at three of the nine crossings such that they do not share a row or column. Therefore the specific candidate can be excluded from all cells in the three rows and in the three columns, except for the nine crossings of the swordfish.


Starting info

Example with candidates

X-wing

 previous   up   next