
Security News
Attackers Are Hunting High-Impact Node.js Maintainers in a Coordinated Social Engineering Campaign
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.
Solves exact cover problems by implementing Donald E. Knuth's Algorithm X using the Dancing Links technique (DLX)
This is a JavaScript library to solve exact cover problems by implementing Donald E. Knuth's Algorithm X using the Dancing Links technique.
var dlxlib = require('dlxlib');
var matrix = [
[1, 0, 0, 0],
[0, 1, 1, 0],
[1, 0, 0, 1],
[0, 0, 1, 1],
[0, 1, 0, 0],
[0, 0, 1, 0]
];
var solutions = dlxlib.solve(matrix);
for (var i = 0; i < solutions.length; i++) {
console.log('solution[%d]: %s', i, JSON.stringify(solutions[i]));
}
// solution[0]: [0,3,4]
// solution[1]: [1,2]
// solution[2]: [2,4,5]
The onSearchStep callback is particularly useful for visualising the progress of the algorithm.
var dlxlib = require('dlxlib');
var matrix = [
[1, 0, 0, 0],
[0, 1, 1, 0],
[1, 0, 0, 1],
[0, 0, 1, 1],
[0, 1, 0, 0],
[0, 0, 1, 0]
];
var searchStepCount = 0;
function onSearchStep(rowIndices) {
console.log('\tpartial solution[%d]: %s', searchStepCount++, JSON.stringify(rowIndices));
}
var solutionCount = 0;
function onSolutionFound(rowIndices) {
console.log('solution[%d]: %s', solutionCount++, JSON.stringify(rowIndices));
searchStepCount = 0;
}
dlxlib.solve(matrix, onSearchStep, onSolutionFound);
// partial solution[0]: []
// partial solution[1]: [0]
// partial solution[2]: [0,3]
// partial solution[3]: [0,3,4]
// solution[0]: [0,3,4]
// partial solution[0]: [2]
// partial solution[1]: [2,1]
// solution[1]: [2,1]
// partial solution[0]: [2,4]
// partial solution[1]: [2,4,5]
// solution[2]: [2,4,5]
var dlxlib = require('dlxlib');
var matrix = [
[1, 0, 0, 0],
[0, 1, 1, 0],
[1, 0, 0, 1],
[0, 0, 1, 1],
[0, 1, 0, 0],
[0, 0, 1, 0]
];
var solutions = dlxlib.solve(matrix, null, null, 1);
if (solutions.length) {
console.log('first solution: %s', JSON.stringify(solutions[0]));
}
// first solution: [0,3,4]
As an alternative to dlxlib.solve, dlxlib.solutionGenerator returns a
Generator.
import { solutionGenerator } from 'dlxlib';
const matrix = [
[1, 0, 0, 0],
[0, 1, 1, 0],
[1, 0, 0, 1],
[0, 0, 1, 1],
[0, 1, 0, 0],
[0, 0, 1, 0]
];
const generator = solutionGenerator(matrix);
const iteratorResult = generator.next();
if (!iteratorResult.done) {
console.log('first solution: %s', JSON.stringify(iteratorResult.value));
}
// first solution: [0,3,4]
FAQs
Solves exact cover problems by implementing Donald E. Knuth's Algorithm X using the Dancing Links technique (DLX)
We found that dlxlib demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.

Security News
Axios compromise traced to social engineering, showing how attacks on maintainers can bypass controls and expose the broader software supply chain.

Security News
Node.js has paused its bug bounty program after funding ended, removing payouts for vulnerability reports but keeping its security process unchanged.