Subsets of a multiset

Here's a version based on Tuples that should be much faster if there are a lot of repeated elements:

Multisubsets[list_] := With[{c = Tally[list]},
    Flatten /@ Tuples @ Replace[
        c,
        {k_, ct_} :> FoldList[Append, {}, Table[k, ct]],
        {1}
    ]
]

For your example:

res = Multisubsets[{a, b, c, c}]

{{}, {c}, {c, c}, {b}, {b, c}, {b, c, c}, {a}, {a, c}, {a, c, c}, {a, b}, {a, b, c}, {a, b, c, c}}

Check:

Sort @ res == DeleteDuplicates @ Subsets[{a, b, c, c}]

True

Timing test:

list = Join[Table[a, 20], Table[c, 3]];
r1 = DeleteDuplicates[Subsets[list]]; //AbsoluteTiming
r2 = Multisubsets[list]; //AbsoluteTiming

r1 == Sort[r2]

{8.36211, Null}

{0.000132, Null}

True

Almost 4 orders of magnitude faster.


I guess what you are after is

newSubsets[set_] := DeleteDuplicates[Subsets[set]];

It provides the result

newSubsets[{a, b, c, c}]
(* {{}, {a}, {b}, {c}, {a, b}, {a, c}, {b, c}, {c, c}, {a, b, 
  c}, {a, c, c}, {b, c, c}, {a, b, c, c}} *)