Constructed using 2d board array Returns: Strategy used to solve each step or null if solved or unsolvable error Solution 2d board array

Hierarchy

  • Solver

Constructors

  • Creates solver object

    Parameters

    • board: string[][]

      2d board array

    • algorithm: StrategyEnum[] = ...

      optional parameter specifying order to apply strategies

    • Optional notes: string[][]

      optional parameter specifying initial state of the notes (one array with an array for each cell in order)

    • Optional solution: string[][]

    Returns Solver

Properties

algorithm: StrategyEnum[]
allHints: Hint[]
board: Cell[][]
cellBoard: CellBoard
emptyCells: Cell[][]
hint: Hint
placedCount: number
solution: string[][]
solved: boolean

Methods

  • Adds every empty cell in board to cells

    Parameters

    • cells: Cell[][]

      cell array

    Returns void

  • Applies hint (places values according to hint)

    Returns void

  • Gets an array containing Hint objects for each strategy that can be used at this step

    Returns

    array of Hints for all applicable strategies at this step

    Returns Hint[]

  • Returns current state of the board being solved

    Returns

    current board array

    Returns string[][]

  • Returns current notes stored by the Solver

    Returns

    array of notes arrays in order (one array with an array for each cell)

    Returns string[][]

  • Returns current notes stored by the Solver

    Returns

    string of notes for each cell going left to right and top to bottom, "0"=note not in cell, "1"=note in cell

    Returns string

  • Returns current number of placed values (including givens)

    Returns

    number of placed values

    Returns number

  • Gets solution array if solved, otherwise throws error

    Returns

    solution array

    Throws

    CustomError Thrown if puzzle isn't solved

    Returns string[][]

  • Checks if puzzle is finished

    Returns

    true if puzzle is finished

    Parameters

    • cells: Cell[][]

      empty cells

    Returns boolean

  • Takes the next step in solving puzzle

    Returns

    hint used or null if finished

    Throws

    CustomError Thrown if board is unsolvable

    Returns Hint

  • Places values from given cells into board

    Parameters

    • cells: Cell[]

      cells array

    Returns void

  • Removes given notes from board

    Parameters

    • notes: Group[]

      Groups containing notes to remove

    • amend: boolean

      If true than cell notes are amended by adding all possible notes to cell before removing any

    Returns void

  • Creates a Hint object for each strategy that can be used at this step and adds it to allHints

    Returns void

  • Sets emptyCells to be all of the empty cells in the board

    Returns void

  • Gets and sets the next hint if a strategy can be applied, otherwise sets to null

    Parameters

    • cells: Cell[][]

      empty cells

    Returns void

  • Sets boards notes to given notes

    Parameters

    • notes: string[][]

      array of notes arrays in order (one array with an array for each cell)

    Returns void

Generated using TypeDoc