0.1.6 • Published 2 years ago
permutationsjs v0.1.6
Description
Generate all possible permutations of given elements.
Install
npm i permutationsjs
Usage
import permutations from 'permutationsjs'
const _permutations = []
permutations(
[0,1], // the elements to permutate
6, // the size of permutations
false, // whether to avoid repetition of elements in the permutations
permutation => _permutations.push(permutation) // a callback on each permutation
)
Algorithm
At each step of the recursion, pick one element and map all other elements to it.