1.0.4 • Published 7 years ago
cargocult v1.0.4
cargocult
Randomized algorithm for arbitrary problems. The name comes from Cargo Cult.
This algorithm is designed for situations when you do not have a clue what you are looking for. If you have some idea of what you are looking for, then you should probably use Monte Carlo or Las Vegas algorithms instead.
Always correct answer | Fixed run time | |
---|---|---|
Las Vegas | Yes | No |
Monte Carlo | No | Yes |
Cargo Cult | No | No |
Installation
yarn add cargocult
Usage
const cargocult = require('cargocult');
/*
* The problem may be anything
* String, Array, Object, Function... whatever
*/
const problem = 'foo bar';
//const problem = [1, 2, 3, 4];
//const problem = {a: 1, b: 2, c: {d: 3}};
//const problem = () => console.log('hello world');
/*
* Syntax: cargocult(problem[, debug])
* By default debug is false
*
* cargocult will return a promise that will eventually resolve the solution
*/
cargocult(problem, true)
.then(console.log);