I'm making a card game and I'd like to get an array of all possible combinations of the cards on the table (including combos that leave cards on the table). So if there were 2 cards on the table it'd return an array like:
buildArray(2) = [
[0],
[1],
[0,1]
]
([0,0]
and [1,1]
would be impossible and [1,0]
would be redundant)
I know I need to use recursion to do so but I've been falling all over it for hours and would love some help at this point.
Another example:
buildArray(3) = [
[0],
[1],
[2],
[0,1],
[0,2],
[1,2],
[0,1,2]
]