Skip to content

Instantly share code, notes, and snippets.

@harishvc
Last active November 30, 2015 04:32
Show Gist options
  • Save harishvc/5acd53d1679a1600a414 to your computer and use it in GitHub Desktop.
Save harishvc/5acd53d1679a1600a414 to your computer and use it in GitHub Desktop.
Find different combinations
# Find different combinations
def combinations(n):
yield ""
for i, d in enumerate(n):
for combination in combinations(n[i+1:]):
yield d + combination
print([x for x in combinations("abc")])
#output
['', 'a', 'ab', 'abc', 'ac', 'b', 'bc', 'c']
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment