Documentation¶
The application is split into a CLI that can be found under app/
and a library (suso
) that does all the heavylifting.
You can find the documentation of the library here.
Glossary¶
- cell
- The cells are the places of a Sudoku where the numbers are placed. A cell can be empty or filled with exactly one number.
- field
- The whole 9x9 grid of a Sudoku with all its 81 cells.
- row
- A row of 9 cells in the field. There are always nine rows in one field.
- column
- A column of 9 cells in the field. There are always nine columns in one field.
- block
- A section of the field with 3x3 cells. There are nine of these non overlapping sections in one field. In the visualized Sudokus they are mostly marked by stronger lines.
- group
- An area where numbers have to be unique in. This can be a block, a row or a column.
Library documentation¶
-
struct
Position
¶ - #include <suso.h>
A position contains the coordinates of one cell inside a Sudoku field.
-
class
Sudoku
¶ - #include <suso.h>
A Sudoku represents the complete field of one Sudoku. It also has functions to solve the Sudoku using different algorithms.
Public Functions
-
Metrics
getSolvingMetrics
()¶ Get information about how this Sudoku has been solved. This is only filled completely after successfully solving it.
- Return
- Metrics about the previous solving process
-
std::vector<int>
validNumbers
(Position pos)¶ This function returns all numbers that could be placed in the cell at the given position so they do not conflict with the numbers already placed in the field.
- Return
- all possible numbers for the position
- Parameters
pos
: the position to check
-
bool
loadFromFile
(std::string path)¶ This function reads a file into the sudoku field.
-
bool
solveNakedSingles
()¶ This function tries to fill cells by searching for naked singles. These are cells where only one number is valid. The function iterates over the whole field and fills in the number when it finds a naked single.
- Return
- true if the field has been changed (at least one number filled into a cell), false otherwise
-
bool
solveHiddenSingles
()¶ This function tries to fill cells by searching for hidden singles. This is a cell that is the only one in a group, that could contain a specific number. The function iterates over all groups and fills in the numbers when it finds hidden singles inside a group.
- Return
- true if the field has been changed (at least one number filled into a cell), false otherwise
-
bool
solveBacktracking
()¶ This function solves the sudoku recursively by using the backtracking algorithm.
- Return
- true if the sudoku is solved
-
void
checkSolvability
() const¶ This function checks if the sudoku is solvable. If the sudoku is not solvable, the function will throw an exception.
Private Functions
-
bool
isEmpty
(Position pos)¶ Returns if a given cell is not filled with a number.
- Return
- true if the cell is empty, false otherwise
- Parameters
pos
: the position to check
-
Metrics