Skip to content

Get all possible permutations of a given length, and a given array of attributes.

Notifications You must be signed in to change notification settings

jonasaurus/permu

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Permu

Get all possible permutations of a given length, and a given array of attributes.

npm install permu

Example

const permu = require("permu");

const items = [1, 2, 3];
const attributes = ["red", "blue"];

const permutations = permu(items.length, attributes);

console.log(permutations);

/*
[ [ 'red', 'red', 'red' ],
  [ 'red', 'red', 'blue' ],
  [ 'red', 'blue', 'red' ],
  [ 'red', 'blue', 'blue' ],
  [ 'blue', 'red', 'red' ],
  [ 'blue', 'red', 'blue' ],
  [ 'blue', 'blue', 'red' ],
  [ 'blue', 'blue', 'blue' ] ]
*/

License

MIT

About

Get all possible permutations of a given length, and a given array of attributes.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published