Last active
August 29, 2015 13:56
-
-
Save balkian/9186870 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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