permutationsjs

0.1.6 • Public • Published

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.

Readme

Keywords

none

Package Sidebar

Install

npm i permutationsjs

Weekly Downloads

0

Version

0.1.6

License

MIT

Unpacked Size

29.1 kB

Total Files

9

Last publish

Collaborators

  • gottfried