Skip to content
Stekeblad edited this page Oct 23, 2017 · 9 revisions

Welcome to the SodukuSolver wiki! The wiki is based on release version 1.0.0

Understanding the UI

Then you first launch SodukuSolver there is not much you can do, the first thing you need to do is to press the "Start/Restart" button. After that the UI looks like this:

UI after Start/Restart is pressed

Then Start/Restart (1) is pressed all the cells for numbers on the top part of the window (7) is created, the presets list is populated (3) and the other buttons is enabled. If (1) is pressed again then all cells and text fields are cleared.

The presets in the list (3) are mainly for testing purpose and is hard-coded soduku boards that can be loaded to the cells above by clicking on one of them and then clicking the "load a default" button (4).

After loading a board or manually entering numbers you can press the "Solve" (2) button to tell the program to attempt solving it. Before the solving actually starts all cells are checked to see if they contain valid characters or is empty. All valid characters is: a single space and the numbers 0 to 9. Any other character or if a cell contains more than one character it is considered invalid content and the position of that cell is displayed in text field (6). Another error at this point is that one number is found to occur more than once in a row, column or square, this will also appear in (6).

The cell the error was found in has two digits, the first tells the row (starting at 0 in the top left corner going down) and the second is the column (starting at 0 in the top left corner going right).

If the test is successful the actual solving begins and a timer is started. The output in text field (6) will now state if the solve was successful or why it wasn't (eg. too hard for the algorithm, no solution) and text field (5) will tell how many microseconds the solve attempt took.

Little about the solving algorithm

The solving function does not 'guess', if it is not sure that a certain number should go in a specific cell it will not place a number in it.

To figure out what to place in a cell the function has four algorithms it is using. Here is a very short description of how they work, for more details check the code (Code starts here).

The first algorithm only places a number in a cell if that number is the only number that can be placed there based on what numbers already exists in that row, column and square.

The second algorithm only places a number in a cell if that is the only cell that number can be placed in that row, column or square.

The first two is very simple but the following starts to get a bit more advanced. But first I need to explain a thing that is going on in the background. To not scan the entire soduku again and again for every number that it tries to place there is a large list containing all currently possible values for every cell and it is created in the beginning. Every time a number is placed the possibilities is updated. The following algorithms does not directly place numbers, they only find numbers that can be excluded from the possibilities list.

The third uses a solving method called "locked candidates" and works like this: type 1: If a number is only possible to place in a single row or a single column inside a square, then all squares in that row/column can have that number's possibilities removed from the row/column in question.

type 2: If a square is alone to be able to have a number on a specific row or column, then all cells in that square that is not on that row/column can have the number's possibilities removed.

The fourth uses a solving method called "naked pairs" and that one works like this: If two cells in a row/column/square can only have two different numbers according to the possibility list and it is the same two numbers, then no other cell on that row/column/square can have that number so it is removed from the other cell's possibilities.

Another explanation (with examples) for the different techniques can be found here: http://www.angusj.com/sudoku/hints.php

Clone this wiki locally