heaps-algorithm

1.0.0 • Public • Published

heaps-algorithm

Heap's algorithm for generating permutations of an array.

installation

npm install heaps-algorithm

usage

This module exports a function, which returns an array of all permutations of the array passed to it.

var permutations = require('heaps-algorithm'),
    actual = permutations([1, 2, 3]),
    expected = [
      [ 1, 2, 3 ],
      [ 2, 1, 3 ],
      [ 3, 1, 2 ],
      [ 1, 3, 2 ],
      [ 2, 3, 1 ],
      [ 3, 2, 1 ]
    ];

assert.deepEqual(actual, expected); // true

Versions

Current Tags

  • Version
    Downloads (Last 7 Days)
    • Tag
  • 1.0.0
    134
    • latest

Version History

  • Version
    Downloads (Last 7 Days)
    • Published
  • 1.0.0
    134

Package Sidebar

Install

npm i heaps-algorithm

Weekly Downloads

7

Version

1.0.0

License

MIT

Last publish

Collaborators

  • phoenixstormcrow