tasks a-s
This commit is contained in:
parent
47bf37c096
commit
b83f433714
12433 changed files with 156208 additions and 123 deletions
14
Task/Power-set/JavaScript/power-set.js
Normal file
14
Task/Power-set/JavaScript/power-set.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