Methods
solutionGenerator(matrix, optionsopt) → {Solution}
Creates an ES2015 Generator object that can be used to iterate over the solutions to the matrix.
This is a convenience function which avoids having to create an instance of the Dlx class.
It is useful if you are not interested in handling any events.
Parameters:
Name | Type | Attributes | Description | ||||||
---|---|---|---|---|---|---|---|---|---|
matrix |
Matrix | The matrix to be solved. | |||||||
options |
object |
<optional> |
Optional options object.
Properties
|
Yields:
The next solution.
- Type
- Solution
solve(matrix, optionsopt) → {Array.<Solution>}
Solves the matrix and returns an array of solutions.
This is a convenience function which avoids having to create an instance of the Dlx class.
It is useful if you are not interested in handling any events.
Parameters:
Name | Type | Attributes | Description | |||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|
matrix |
Matrix | The matrix to be solved. | ||||||||||
options |
object |
<optional> |
Optional options object.
Properties
|
Returns:
The solutions that were found.
- Type
- Array.<Solution>
Type Definitions
Matrix
A matrix is an array of MatrixRow.
Type:
- Array.<MatrixRow>
MatrixRow
A matrix row is an array of MatrixValue.
Type:
- Array.<MatrixValue>
MatrixValue
Matrix values can be of any type. Anything truthy is treated as a 1. Anything falsy is treated as a 0.
Type:
- *
PartialSolution
The indices of the matrix rows that comprise a partial solution.
Type:
- Array.<number>
Solution
The indices of the matrix rows that comprise a complete solution.
Type:
- Array.<number>