-
Notifications
You must be signed in to change notification settings - Fork 5
permutations
wolfram77 edited this page Mar 26, 2020
·
21 revisions
Lists all possible permutations.
array.permutations(x);
// x: an array
// --> ...permutations
const array = require('extra-array');
[...array.permutations([1, 2])];
// [ [ 1, 2 ], [ 2, 1 ] ]
[...array.permutations([1, 2, 3])];
// [
// [ 1, 2, 3 ],
// [ 2, 1, 3 ],
// [ 1, 3, 2 ],
// [ 3, 1, 2 ],
// [ 2, 3, 1 ],
// [ 3, 2, 1 ]
// ]