I have a List<Object>
. I have an int maxSize. I want a List<List<Object>>
containing all combinations of objects of maxSize (this lists are maxSize, not the objects), or less.
I've seen solutions to problems that looks like my problem, except they aren't my problem and evidently my brain isn't smart enough to figure it out. I've also already spent 3 days on my overall problem trying to recurse myself to oblivion, so I'm just looking for solutions that just work at that point.
Requirements:
- It has to return a
List<List<Object>>
, not anything else. - It has to take a
List<Object>
and int as arguments. If it needs more arguments for recursion or whatever, it's fine. The first two args are still aList<Object>
and an int, not anything else. - Each
List<Object>
can only be of maxSize, or less. The "or less" requirement is optional, I can work without it. - Order does not matter. {1,2} equals {2,1}.
- Duplicates are not allowed. If it contains {1,2}, it cannot contain {2,1}.