rand-perm
v1.1.0
Published
randomly shuffles element between 0 and n-1 (<n)
Downloads
8
Maintainers
Readme
rand-perm
returns an array of random permutation efficiently(O(n))
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