Dlx

Dlx

Use this class if you want to handle Dlx#event:step or Dlx#event:solution events. Otherwise, it is easier to use the global functions, solve and solutionGenerator.

Constructor

new Dlx()

Source:

Methods

(generator) solutionGenerator(matrix, optionsopt) → {Solution}

Source:
Creates an ES2015 Generator object that can be used to iterate over the solutions to the matrix.
Parameters:
Name Type Attributes Description
matrix Matrix The matrix to be solved.
options object <optional>
Additional options object.
Properties
Name Type Attributes Description
numPrimaryColumns number <optional>
The number of primary columns. By default, all columns are primary. Any remaining columns are considered to be secondary columns.
Fires:
Yields:
The next solution.
Type
Solution

solve(matrix, optionsopt) → {Array.<Solution>}

Source:
Solves the matrix and returns an array of solutions.
Parameters:
Name Type Attributes Description
matrix Matrix The matrix to be solved.
options object <optional>
Additional options object.
Properties
Name Type Attributes Description
numSolutions number <optional>
The number of solutions to be returned. By default, all solutions are returned.
numPrimaryColumns number <optional>
The number of primary columns. By default, all columns are primary. Any remaining columns are considered to be secondary columns.
Fires:
Returns:
The solutions that were found.
Type
Array.<Solution>

Events

solution

Source:
Properties:
Name Type Description
solution Solution A solution to the matrix.
solutionIndex number The index of this solution (0, 1, 2, ...).
Solution event - fired for each solution found.
Type:
  • object

step

Source:
Properties:
Name Type Description
partialSolution PartialSolution The current partial solution at this step of the algorithm.
stepIndex number The index of this step of the algorithm (0, 1, 2, ...).
Step event - fired for each step of the algorithm.
Type:
  • object