Skip to content

Instantly share code, notes, and snippets.

@yasith
Created April 20, 2012 02:52
Show Gist options
  • Save yasith/2425536 to your computer and use it in GitHub Desktop.
Save yasith/2425536 to your computer and use it in GitHub Desktop.
PowerSet
def powerset(L):
ret = [tuple(L)]
if len(L) == 0:
return ret
for i in range(len(L)):
ret += powerset(L[:i] + L[i+1:])
return list(set(ret))
print powerset([1,2,3])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment