2016 Update
This commit is contained in:
parent
948b86eafa
commit
dcf5d15da3
7965 changed files with 139854 additions and 31002 deletions
|
|
@ -5,18 +5,18 @@ var d = document.getElementById('result');
|
|||
|
||||
function perm(list, ret)
|
||||
{
|
||||
if (list.length == 0) {
|
||||
var row = document.createTextNode(ret.join(' ') + '\n');
|
||||
d.appendChild(row);
|
||||
return;
|
||||
}
|
||||
for (var i = 0; i < list.length; i++) {
|
||||
var x = list.splice(i, 1);
|
||||
ret.push(x);
|
||||
perm(list, ret);
|
||||
ret.pop();
|
||||
list.splice(i, 0, x);
|
||||
}
|
||||
if (list.length == 0) {
|
||||
var row = document.createTextNode(ret.join(' ') + '\n');
|
||||
d.appendChild(row);
|
||||
return;
|
||||
}
|
||||
for (var i = 0; i < list.length; i++) {
|
||||
var x = list.splice(i, 1);
|
||||
ret.push(x);
|
||||
perm(list, ret);
|
||||
ret.pop();
|
||||
list.splice(i, 0, x);
|
||||
}
|
||||
}
|
||||
|
||||
perm([1, 2, 'A', 4], []);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue