1.1.0 • Published 6 years ago

rand-perm v1.1.0

Weekly downloads
4
License
MIT
Repository
github
Last release
6 years ago

rand-perm

returns an array of random permutation efficiently(O(n))

Build Status

Usage

Installation

  $ npm install rand-perm

Examples

  var randPerm = require('rand-perm')

  console.log(randPerm(3)) // [ 2, 0, 1 ]
  console.log(randPerm(3)) // [ 1, 0, 2 ]

  console.log(randPerm(4)) // [ 0, 2, 1, 3 ]
  console.log(randPerm(4)) // [ 2, 0, 1, 3 ]

  console.log(randPerm(5)) // [ 1, 0, 4, 2, 3 ] 
  console.log(randPerm(5)) // [ 2, 0, 3, 1, 4 ] 

API

rand-perm(n)

returns an array with elements from 0 to n-1 in a random way

License

MIT