Skip to content

Instantly share code, notes, and snippets.

@RedaAffane
Created May 14, 2018 09:47
Show Gist options
  • Save RedaAffane/118a0b4448fa0b744fc48a2a0a2e283b to your computer and use it in GitHub Desktop.
Save RedaAffane/118a0b4448fa0b744fc48a2a0a2e283b to your computer and use it in GitHub Desktop.
def subsets(s):
'''
This function returns all the possible subsets of a set of channels.
input :
- s: a set of channels.
'''
if len(s)==1:
return s
else:
sub_channels=[]
for i in range(1,len(s)+1):
sub_channels.extend(map(list,itertools.combinations(s, i)))
return map(",".join,map(sorted,sub_channels))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment