Skip to content

Instantly share code, notes, and snippets.

@karthikbgl
Created October 24, 2015 04:46
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save karthikbgl/b9ac1f59ddd874f87e02 to your computer and use it in GitHub Desktop.
Save karthikbgl/b9ac1f59ddd874f87e02 to your computer and use it in GitHub Desktop.
All possible combinations of substrings
import itertools
def yieldSubset(s):
return sorted(list(set([''.join(c) for i in range(len(s)+1) for c in itertools.combinations(s, i) if c])))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment