Skip to content

Instantly share code, notes, and snippets.

@balkian
Last active August 29, 2015 13:56
Show Gist options
  • Save balkian/9186870 to your computer and use it in GitHub Desktop.
Save balkian/9186870 to your computer and use it in GitHub Desktop.
Display the source blob
Display the rendered blob
Raw
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
def frozen_combination(*args):
combinations = set([frozenset(),])
for arg in args:
tempcomb = set(frozenset(),)
for i in set(arg):
tempcomb.update(set([frozenset(list(c)+[i]) for c in combinations if i not in c]))
if len(tempcomb) > 0:
combinations = tempcomb
return combinations
# return [set(comb) for comb in combinations] # for sets instead of frozensets
res = frozen_combination(a,b)
print res
print len(res)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment