I'm trying to find an elegant way to generate all possible combinations from an initial flat list.
For example:
[In:]
l = ["aaa", "bbb", "ccc"]
[Out:]
[["aaa"], ["bbb"], ["ccc"]]
[["aaa", "bbb"], ["ccc"]]
[["aaa", "ccc"], ["bbb"]]
[["bbb", "ccc"], ["aaa"]]
[["aaa", "bbb", "ccc"]]
As you see here the order doesn't matter for me. So I would avoid to obtain such cases:
[["aaa"], ["bbb"], ["ccc"]]
[["bbb"], ["aaa"], ["ccc"]]
...
[["ccc"], ["aaa"], ["bbb"]]
Also each sublist of my output list has to contain every element of my initial list.
I din't find any obvious solution with itertools.combination()
Thanks