find all unique substring permutations of a string of a specific length python

Solutions on MaxInterview for find all unique substring permutations of a string of a specific length python by the best coders in the world

showing results for - "find all unique substring permutations of a string of a specific length python"
Ewen
07 Jan 2017
1import itertools
2
3x = "some string"
4
5# aList contains all permutations of all lengths of string x
6aList = [each for eachpermut in [''.join(l) for i in range(len(x)) for l in itertools.combinations(x, i+1)] for each in [''.join(eachpermut) for eachpermut in list(itertools.permutations(eachpermut))]]
7
8# aSet only contains unique permutations of aList of varying lengths
9aSet = set(aList))