import { Grid } from '../Grid'; import { Cell } from '../Cell'; import { CellCollection } from '../CellCollection'; import { CellValueChange, GridLocation, SudokuPossibleValue, ValueComboType } from '../ValueTypes'; /** * Defines the result of applying changes to a Grid. */ export interface ChangeResult { grid: Grid; changes: CellValueChange[]; } /** * Structure to help reduce found values into values and counts at a location. */ export interface ReducedValues { 1?: GridLocation[]; 2?: GridLocation[]; 3?: GridLocation[]; 4?: GridLocation[]; 5?: GridLocation[]; 6?: GridLocation[]; 7?: GridLocation[]; 8?: GridLocation[]; 9?: GridLocation[]; } /** * Implements a class that provides helper methods for solving puzzles. */ export declare class SolverHelpers { /** * Applies a list of changes to a Grid and returns a new grid with the results. * @param grid A reference to a Grid to apply the changes to. * @param changes A list of cxhanges to apply to the Grid. * @returns An object holding the new grid. */ static applyChangeList(grid: Grid, changes: CellValueChange[]): Grid; /** * Pivots the cell values into an object that provides the frequency and locations * of values in the specified row, column or block. * TODO: See if there is a simpler way to do this which could removed code complexity. * @param block A reference to a Grid Row, Column or Block. * @returns A reference to a ReducedValues object that shows value frequency. */ static reduceCells(block: CellCollection): ReducedValues; /** * Scans a row, column or block for a unique combination of n cells. The number of cells * returned (n) is provided by the caller in the groupsOf parameter. The caller provides * a callback function to process the groups and if the callback function returns true, * that group will be added to the Cell[][] returned value. * If you pass in an array of cells that is not 9 Cells long, an error is thrown. * @param block A CellCollection containing a row, column or block to be scanned. * @param groupsOf The number of cells to return in each combination. * @param callback A callback method to receive each cell combination. * @returns An array of Cell[] where the callback function returned true. */ static scanBlock(block: CellCollection, groupsOf: SudokuPossibleValue, callback: (cells: Cell[], block: Cell[]) => boolean): Cell[][]; /** * Runs a naked cell solver for a row, column or block. * @param block A reference to a row, column or block to process. * @param comboType The type of combo to process. * @param source string to say where the changes have come from. * @returns A set of changes to apply to the target grid or an empty array if * no naked cells are found. */ static processNakedCellsInBlock(block: CellCollection, comboType: ValueComboType, source: string): CellValueChange[]; /** * Searches a given row, column or block for hidden values and returns an * array of objects to remove unneeded potentials in those cells. * @param block A reference to a row, column or block to process. * @param groupsOf Whether to serch for pairs, triples, or quads. * @param source The source solver to add to the change messages. * @returns An array of GridDifference objects to apply back to the Grid. */ static processHiddenCellsInBlock(block: CellCollection, groupsOf: SudokuPossibleValue, source: string): CellValueChange[]; /** * Searches the targetGrid for naked pairs, truples or quads and returns a list of potentials that * need to be updated to the caller. * @param helperFn A function to call that will find the changes needed to solve a basic cell combination. * @param targetGrid The grid to solve. * @param comboType A ValueComboType describing whether we're looking for Pairs, Triples or Quads. * @param source The name of the solver that will be passed as part of the changes array. * @returns An array of CellValueChange objects describing the changes to make. */ static solveSimpleMultiples(helperFn: (targetGrid: CellCollection, comboType: ValueComboType, source: string) => CellValueChange[], targetGrid: Grid, comboType: ValueComboType, source: string): CellValueChange[]; /** * Searches the targetGrid for naked pairs, truples or quads and returns a list of potentials that * need to be updated to the caller. * @param targetGrid The grid to solve. * @param comboType A ValueComboType describing whether we're looking for Pairs, Triples or Quads. * @param source The name of the solver that will be passed as part of the changes array. * @returns An array of CellValueChange objects describing the changes to make. */ static solveNakedMultiples(targetGrid: Grid, comboType: ValueComboType, source: string): CellValueChange[]; /** * Searches the targetGrid for hidden pairs, truples or quads and returns a list of potentials that * need to be updated to the caller. * @param targetGrid The grid to solve. * @param comboType A ValueComboType describing whether we're looking for Pairs, Triples or Quads. * @param source The name of the solver that will be passed as part of the changes array. * @returns An array of CellValueChange objects describing the changes to make. */ static solveHiddenMultiples(targetGrid: Grid, comboType: ValueComboType, source: string): CellValueChange[]; /** * Searches the grid provided for intersecting blocks, rows and columns * where potential removals can take place. Returns an array of CellValueChange * objects to make the required changes. * array of changes to apply to the target grid. * @param targetGrid The grid to solve. * @param solveFn A function that can solve for a given block and row / column. * @returns An array of changes to apply to the grid to solve it. */ static solveBoxLineReduction(targetGrid: Grid, solveFn: (blockCells: CellCollection, rowOrColumnCells: CellCollection) => CellValueChange[]): CellValueChange[]; /** * Implements the Intersection Removal solver for a given block and row / column. * @param blockCells The block of cells we're checking for intersections. * @param rowOrColumnCells The row or column we're checking for intersections. * @param outside 'line' or 'box'. If 'line' values will be removed from the intersecting line. * if 'block' they will be removed from the block. * @param source The name of the source solver. * @returns An array of CellValueChange objects describing the changes to apply to targetGrid. */ static solveBoxLineReductionForBlockAndRow(blockCells: CellCollection, rowOrColumnCells: CellCollection, outside: 'line' | 'box', source: string): CellValueChange[]; }