Information Technology
DE | ENContact

Handling Summary

Clickselects a cell
Number keyenters the number into the selected cell
Ctrl+ Number keyenters or removes the candidate in the selected cell (in the candidate view)

The Sudoku Rule

There is only one rule for the Sudoku game:
Fill the 9x9 grid with the numbers 1 to 9 such that each row, each column and each 3x3 block does not contain a duplicate number, i.e. all these regions must contain all the numbers 1 to 9.

General Usage

This Sudoku Player supports you in solving Sudoku puzzles that you find in newspapers, books and on the Internet. You can also request puzzles in three difficulty degrees. The main features of the player are:

The game has two phases:

Phase 1

In the first phase you enter the puzzle as you find it in the newspaper or on the Internet.

During this phase you can arbitrarily edit the values in the cells. When you click on a cell it becomes green indicating that you can enter a number 1 .. 9 by pressing the respective key on the keyboard. You can overwrite the number by typing another number or you can clear the cell by pressing one of the keys: x, 0, Del, Enter. When you have completed the initial position, click the button Freeze. The entered numbers become "frozen" (colored black), they cannot be edited any more.

You can also get a Sudoku puzzle as a string e.g. on www.sudocue.net. You would copy and paste it into the text field below the grid and then press the button Enter to insert it into the Sudoku board.

You can also request a puzzle from this site. Select a difficulty level and press the button "Get New Puzzle". A puzzle will be filled into the board. All requested puzzles can be solved by logical rules only. The difficulty levels have the following meaning:

LevelSolution Strategies
Easy Naked Single
Hidden Single
Medium Block/Row Intersection
Block/Column Intersection
Naked Pair
Hard Naked Triple
Hidden Pair
Hidden Triple
X-Wing

Phase 2

In the second phase you solve the puzzle. Again, you click on a cell to insert a number. Now, you cannot delete the number, but you can "undo" (and "redo") your move. This guarantees that you delete numbers in the opposite order than you entered them which is important for various solution strategies. You recognize the last entered cell by a gray color - this cell will be cleared when you press the Undo button.

The check box Show Candidates (or the key combination Ctrl c) toggles between the normal view and the "Candidate View". The candidates are the values that can still be entered in a cell without violating the Sudoku constraints. One of the candidates is the solution value. Candidates can be edited: pressing a number key together with the Ctrl- or Alt-key toggles the presence of a candidate value (in the Candidate View). This feature supports the application of advanced solution strategies. You can still enter cell values in the Candidates View by pressing the respective key.

The changed candidates cannot be "undone" but they can be recomputed by pressing Recompute Candidates. This command resets all empty cells to maximal number of candidates that are consistent with the values of filled cells and cleans up your candidate changes.

The command Check Consistency checks whether the values inserted so far are consistent with the Sudoku rules. The command does not check whether the cell values are the solution values.

Commands

Enter New Puzzle
Starts a new game. The current board is cleared, the shown solution is deleted.
Freeze
Freezes the current cell values making them the initial position for solving.
Get New Puzzle
Gets a new puzzle with the selected difficulty level. The current board is cleared, the shown solution is deleted.
Show Candidates
The button Show Candidates or the check box or the key combination Ctrl c toggle between the normal view and the "Candidate View".
Recalculate Candidates
Candidates are recalculated based on the values of the filled cells. The empty cells obtain the maximal number of candidates that are consistent with the Sudoku rules. Edited candidates are lost.
Check Consistency
The filled cells are checked for consistency with the Sudoku rules. It is not checked whether the cell values are the solution values.
Clear All
All filled non-frozen cells are cleared and the candidates are recalculated.
Undo
The last entered cell, which is indicated by a gray background, will be cleared and all candidates will be recalculated. After this command the second last cell becomes gray and can be undone and so on.
Redo
Redo revokes the last Undo command.
Solution
The Sudoku is solved and the solution is shown below.
This functionality is available during approximatively 2 hours. Afterwards it is necessary to refresh the browser window and the current puzzle is deleted. If you want to continue with the current puzzle you need to save it and restore it afterwards:
  1. Copy the string below the grid into an editor.
  2. Refresh the browser by clicking the browser's refresh button.
  3. Click the button 'Enter New Game'.
  4. Copy the saved puzzle string from the editor into the field below the grid.
  5. Click the button 'Enter' beside the entered string.
  6. Continue with solving the puzzle.
Enter
Enters the string on the left of the button into the Sudoku board. The command is enabled only during the initial phase.

Mouse and Keys

Mouse Click
Click on a cell to select it for entering a number. The cell's background becomes green.
Keys 1, 2, ... 9
A number key enters the respective number into the selected cell.
Ctrl + 1, 2, ... 9
Pressing a number key together with the Control or Alt key toggles the respective candidate in the selected cell (in the Candidate View only).
Ctrl + c
The key combination Ctrl c toggles between the normal view and the "Candidate View".

Browser Compatibility

The player has been tested with the following browsers on Windows XP:

Implementation Remarks

Generating of Sudoku Puzzles

I generate the Sudoku puzzles offline with a C++ programm. First I construct a randomly filled Sudoku using backtracking. Then, I remove numbers at randomly chosen symmetrical positions and try to solve this Sudoku with the programmed logical rules. If I find a solution, then I have constructed a puzzle. If the Sudoku cannot be solved with the logical rules, I try another starting position. I need about 100'000 trials to generate a "difficult" Sudoku.

Solving of Sudoku Puzzles

By pressing the button "Solution" the current puzzle is solved on the server using backracking. Originally, I programmed the algorithm in PHP which was sufficient for all generated puzzles. It proved rather slow for difficult puzzles. So, the 17-puzzle
080004000000003005005000007002000000000070006400001030000000000000000140007250000
with the solution
789564321624713985315982467972635814831479256456821739293146578568397142147258693
took about 21 seconds.

I ported the algorithm to Perl. The program was rather ugly as expected but the solution time was reduced to 4 seconds probably due to the availability of random-access arrays in Perl.

I was curios about the performance of Python and ported the algorithm also to this language. The program is nice and to my surprise it solves the puzzle in only 2 seconds. Bravo Python!