Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function subset(set){
- var res=[], i=0, lim = Math.pow(2,set.length);
- for(;i<lim;i++){
- var n=i, rtmp=[], j=0;
- while(n!=0){
- var x = n%2;
- if( x==1 )
- rtmp.push(set[j]);
- j++;
- n = (n-x)/2;
- }
- res.push(rtmp);
- }
- return res;
- }
Advertisement
Add Comment
Please, Sign In to add comment