Solution methods

The strategy for solving a puzzle may be regarded as comprising a combination of three processes: scanning, marking up, and analysing.

Scanning

Scanning is performed at the outset and periodically throughout the solution. Scans may have to be performed several times in between analysis periods. Scanning consists of two basic techniques:

Advanced solvers look for "contingencies" while scanning-that is, narrowing a number's location within a row, column, or region to two or three cells. When those cells all lie within the same row (or column) and region, they can be used for elimination purposes during cross-hatching and counting (Contingency example at Puzzle Japan). Particularly challenging puzzles may require multiple contingencies to be recognized, perhaps in multiple directions or even intersecting-relegating most solvers to marking up (as described below). Puzzles which can be solved by scanning alone without requiring the detection of contingencies are classified as "easy" puzzles; more difficult puzzles, by definition, cannot be solved by basic scanning alone.

Marking up

Scanning comes to a halt when no further numbers can be discovered. From this point, it is necessary to engage in some logical analysis. Many find it useful to guide this analysis by marking candidate numbers in the blank cells. There are two popular notations: subscripts and dots.

An alternative technique that some find easier is to mark up those numbers that a cell cannot be. Thus a cell will start empty and as more constraints become known it will slowly fill. When only one marking is missing, that has to be the value of the cell.

Analyzing

The two main approaches to analysis are "candidate elimination" and "what-if".

Ideally one needs to find a combination of techniques which avoids some of the drawbacks of the above elements. The counting of regions, rows, and columns can feel boring. Writing candidate numbers into empty cells can be time-consuming. The what-if approach can be confusing unless you are well organised. The proverbial Holy Grail is to find a technique which minimises counting, marking up, and rubbing out.

Computer solutions

For computer programmers, coding the search for cell values based on elimination, contingencies and multiple contingencies (required for harder Sudoku) is relatively straightforward. These programs emulate the human logic to solve a puzzle without resorting to guesses. Given the self-imposed constraints of most Sudoku publishers, this method generally succeeds.

It is also fairly simple to build a backtracking search. Typically this involves assigning a value (say, 1, or the nearest available number to 1) to the first available cell (say, the top left hand corner) and then moves on to assign the next available value (say, 2) to the next available cell. This continues until a conflict occurs, in which case the next alternative value is used for the last cell changed. If a cell cannot be filled, the program backs up one level (from that cell) and tries the next value at the higher level (hence the name backtracking). Although far from computationally efficient, this "brute force" method will find a solution, given sufficient computation time. A standard 9×9 puzzle can typically be "solved" in under two seconds using almost any programming language. An extremely difficult puzzle can take as much as 1 minute. A more efficient program could keep track of potential values for cells, eliminating impossible values until only one value remains for a cell, then filling that cell in and using that information for more eliminations, and so on until the puzzle is solved.

Another alternative uses finite domain constraint programming. A constraint program specifies the constraints of the puzzle (the fact that every number in each row, each column, and each 3×3 region must be unique, and the provided "givens"); a finite domain solver applies the constraints successively to narrow down the solution space until a solution is found. Backtracking may be applied when alternate values cannot otherwise be excluded.

A highly efficient way of solving such constraint problems is the Dancing Links Algorithm, by Donald Knuth. This method can be directly applied to solving Sudoku problems, counting all possible solutions for most puzzles in milliseconds. This is the method now preferred by many Sudoku programmers, mainly by virtue of its speed. A very fast solver is usually required for most trial-and-error puzzle-creation algorithms.

Sudoku Sudoku Web-Ring Community
« Previous - Next » -Join-
Hosting: SpiritusTemporis.com