Initial data commit
This commit is contained in:
parent
72d218235f
commit
f23f22d71c
199087 changed files with 3378941 additions and 0 deletions
12
Task/Permutations/JavaScript/permutations-2.js
Normal file
12
Task/Permutations/JavaScript/permutations-2.js
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
function perm(a) {
|
||||
if (a.length < 2) return [a];
|
||||
var c, d, b = [];
|
||||
for (c = 0; c < a.length; c++) {
|
||||
var e = a.splice(c, 1),
|
||||
f = perm(a);
|
||||
for (d = 0; d < f.length; d++) b.push([e].concat(f[d]));
|
||||
a.splice(c, 0, e[0])
|
||||
} return b
|
||||
}
|
||||
|
||||
console.log(perm(['Aardvarks', 'eat', 'ants']).join("\n"));
|
||||
Loading…
Add table
Add a link
Reference in a new issue