1.0.4 • Published 7 years ago

cargocult v1.0.4

Weekly downloads
-
License
MIT
Repository
github
Last release
7 years ago

cargocult

NPM

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 answerFixed run time
Las VegasYesNo
Monte CarloNoYes
Cargo CultNoNo

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);
1.0.4

7 years ago

1.0.3

7 years ago

1.0.2

7 years ago

1.0.1

7 years ago

1.0.0

7 years ago

0.1.0

7 years ago