fast-sudoku-solver
Version:
A fast Sudoku solver written in TypeScript.
51 lines (50 loc) • 2.41 kB
TypeScript
/**
* Finds possible entries for a specific field in a Sudoku puzzle.
* @param sudoku the Sudoku puzzle to check
* @param row row of the field to check
* @param column column of the field to check
* @returns possible entries which are not yet in conflict with any other field
*/
export declare function getPossibleEntries(sudoku: number[][], row: number, column: number): number[];
/**
* Generates a new Sudoku puzzle with the exact same entries.
* @param sudoku Sudoku puzzle to clone
* @returns clone of the Sudoku puzzle
*/
export declare function cloneSudoku(sudoku: number[][]): number[][];
/**
* Checks whether a Sudoku puzzle is completely solved. In particular, this functions checks that every number is used exactly once in every row, column, and box.
* @param sudoku the Sudoku puzzle to check
* @returns true if, and only if, the Sudoku puzzle is completely and correctly solved
*/
export declare function isCorrectlySolved(sudoku: number[][]): boolean;
/**
* Checks for each row of the Sudoku puzzle whether every number is used exactly once.
* @param sudoku the Sudoku puzzle to check
* @returns true, if and only if, every number is used exactly once in every row
*/
export declare function allRowsValid(sudoku: number[][]): boolean;
/**
* Checks for each column of the Sudoku puzzle whether every number is used exactly once.
* @param sudoku the Sudoku puzzle to check
* @returns true, if and only if, every number is used exactly once in every column
*/
export declare function allColumnsValid(sudoku: number[][]): boolean;
/**
* Checks for each box of the Sudoku puzzle whether every number is used exactly once.
* @param sudoku the Sudoku puzzle to check
* @returns true, if and only if, every number is used exactly once in every box
*/
export declare function allBoxesValid(sudoku: number[][]): boolean;
/**
* Calculates the first row of a box in a Sudoku puzzle. The boxes are counted row-wise.
* @param boxNumber number of the box in the Sudoku puzzle (counted row-wise)
* @returns first row of the box
*/
export declare function getFirstRowOfBox(boxNumber: number): number;
/**
* Calculates the first column of a box in a Sudoku puzzle. The boxes are counted row-wise.
* @param boxNumber number of the box in the Sudoku puzzle (counted row-wise)
* @returns first column of the box
*/
export declare function getFirstColumnOfBox(boxNumber: number): number;