• + 0 comments

    Python oneliners:

    from itertools import combinations
    def solve(s):
        return sorted(''.join(x) for r in range(1,1+len(s)) for x in combinations(s,r))
    

    Or for the fun to use accumulate instead of range(len()):

    from itertools import combinations, accumulate
    def solve(s):
        return sorted(''.join(x) for r in accumulate(s) for x in combinations(s,len(r)))