Created
May 1, 2009 03:38
-
-
Save bemasher/104855 to your computer and use it in GitHub Desktop.
This file contains 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 PowerSet(base): | |
power_set = [] | |
b = len(base) | |
map(lambda g: power_set.append(map(lambda x: base[x], | |
filter(lambda x: g[x], range(0, b)))), | |
map(lambda value: map(lambda x: (value >> x) & 1, range(b - 1, -1, -1)), | |
map(lambda value: value ^ (value / 2), range(0, 2**b)))) | |
return power_set | |
print PowerSet([1,2,3]) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment