Copyright © 2024 Jiri Kriz,

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: Define the Puzzle

In the first phase you define the puzzle.

During this phase you can arbitrarily edit the values in the cells. Click in the "definition row"


on a number - the number gets selected. Click now on an empty field on the board. The selected number will be input there. You can overwrite a number with another one, or you can delete a number when you select "X" in the definition row first.>

You can enter numbers into the board also using the keyboard. First you need to deselect the selected number in the definition row by clicking on it. Now you can select a field on the board by clicking on it and then type a number on a keyboard to enter it into the selected field. When using the keyboard you delete numbers by typing one of 'x', 'del', 'enter', '0'. If a field on the board is selected you can also click a number in the definition row to enter it into the selected field.

So, there are two input methods. You switch from one method to the other one by deselecting the current selection in the definition row or in the board by clicking on it. As soon as nothing is selected, the first subsequent click in the definition row or in the board defines the new input method.

As soon as you are finished with the set up of the puzzle, click on the tab "Solve" to switch to the solving mode.

You can also request a predefined puzzle. Select a difficulty level and press the button "Request 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

You can also enter the Sudoku puzzle also as a string e.g.


The string represents the numbers on the board in the row-wise order. Empty cells are represented by "0" or ".".

Enter such a string into the respective field and press the button Set Puzzle.

Phase 2: Solve the Puzzle

In the second phase you solve the puzzle. Click on an empty cell to insert a number using the methods described above. Now, you cannot delete a number directly, but you can "undo" (and "redo") your input. This guarantees that you delete numbers in the opposite order as you entered them which is important for various solution strategies.

The button Show Candidates 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 are automatically recomputed during the game.

Candidates can also be edited. Press the button Edit Candidates to enable this mode. Entering numbers in this mode means editing the candidates in fact entering or deleting candidates. The candidates are not automatically recomputed in this mode but you can trigger the recomputing by pressing the button Recompute Candidates. Your candidat changes are obviously lost by this action.


Enters the definition mode. A new puzzle is defined.
Request Puzzle
Gets a new puzzle with the selected difficulty level.
Set Puzzle
Enters the puzzle encoded as a string into the Sudoku board.
Delete All
The board and the input string are deleted.
Enters the solution mode. The defined puzzle is solved.
Removes the entered numbers in the reversed order of the input.
Enters numbers back that were removed using Undo.
Show Candidates
The still available candidates are shown.
Edit Candidates
Entered numbers refer to the candidates that are added or removed according to the current state of a cell.
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.
Clear All
All cells entered in the solution phase are cleared.
Show Solution
The Sudoku is solved and the solution is shown below.

Mouse and Keys

Mouse Click in the Definition Row
A click on a number that is not selected selects this number for the input in the board. If a cell on the boars had already been selected then the definition number is entered into the selected cell on the board. A click on a number that is selected deselects this number.
Mouse Click on the Board
If a definition number is selected then this number is entered into the clicked cell on the board. If no definition number is selected then the clicked cell on the board. becomes selected for a subsequent input. A click on a cell that is selected deselects this cell.
Keys 1, 2, ... 9
A number key pressed on the keyboard enters this number into the selected cell.
Keys 'x', 'del', 'enter', '0'
If a board cell is selected in the definition phase then this cell is cleared.

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

Sudoku puzzles are solved using the Javascript program "kudoku" (see Attractive Chaos - kudoku)