Initial data commit
This commit is contained in:
parent
72d218235f
commit
f23f22d71c
199087 changed files with 3378941 additions and 0 deletions
14
Task/Power-set/JavaScript/power-set-1.js
Normal file
14
Task/Power-set/JavaScript/power-set-1.js
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
function powerset(ary) {
|
||||
var ps = [[]];
|
||||
for (var i=0; i < ary.length; i++) {
|
||||
for (var j = 0, len = ps.length; j < len; j++) {
|
||||
ps.push(ps[j].concat(ary[i]));
|
||||
}
|
||||
}
|
||||
return ps;
|
||||
}
|
||||
|
||||
var res = powerset([1,2,3,4]);
|
||||
|
||||
load('json2.js');
|
||||
print(JSON.stringify(res));
|
||||
Loading…
Add table
Add a link
Reference in a new issue