Each Answer to this Q is separated by one/two green lines.
This is not a exact duplicate of How to get all possible combinations of a list’s elements?
This topic is about finding unique combinations while the other topic is about finding ALL combinations.
If I have a python list:
L = [1,2,3,4]
what’s the best way to get all the possible unique combinations of 3 elements from the list like below:
["1,2,3", "1,2,4", "2,3,4", "3,4,1"]
The order of the elements in the combinations doesn’t matter. For example,
"3,2,1" will be considered the same combination.
I can probably write a few loops to do this but I think there might be a one-liner which can do the same.