# Get all subsets of an ArrayList.

I have an ArrayList 'System.Collections.ArrayList' in Powershell which contains a number of numeric items e.g. 5, 10. I am looking for a way I can find all subsets of this array so for the example here it would be...

5,
10
5,10

The order of the sets is not important so set (5, 10) is the same as (10, 5) and am empty set should not count... In reality the array list I have is much larger - any ideas?
Blowfelt82

It also may be important to note that the list may at some point have duplicate items - this is not the case at the moment but would be good to future proof any solution?
what do u mean subsets of this array?
Please post atleast 10 items in the array please so that we can get clear idea what the problem is.
d-glitch

membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
>>  Note that this works with duplicate elements as well.

Actually, duplicate elements may be a little tricky.

If your set contains duplicates, presumably the subsets can as well.
But the binary counting will generate multiple copies of some subsets.
Suppose your set consists of N items (no duplicates) plus D copies of another item.

The total number of subsets would be  (2^N)*(D+1)

You would generate the subsets of the N unique items as mentioned earlier.
Then you would add 0, 1, 2, ... N copies of the duplicated items.

The mathematics always includes the empty set. You can discard if you wish.

You can extend the math and generation procedure for multiple duplicated items.