I have a list with repeated elements, such as

`list = {a, a, b, c, c, c}`

and I’d like a list of the *unique* ways to choose 3 elements from it:

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

Alas, “unique” means two different things at once in that sentence, and I can’t figure out how to achieve both types of uniqueness simultaneously.

I could use `Permutations`

, whose documentation indicates regarding the input that

Repeated elements are treated as identical.

But I will have many results that differ only by rearrangement, and I do not care about order:

`Permutations[list, {3}]`

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

To eliminate the rearrangements, I could try using `Subsets`

instead, but per *its* documentation,

Different occurrences of the same element are treated as distinct.

As a result I get many duplicate results that I don’t want due to the repeated elements of `list`

:

`Subsets[list, {3}]`

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

[Frustrated aside: I can’t begin to imagine why Mathematica’s permutations-generating function treats repeated list items differently than its combinations-generating function.]

I could eliminate the duplicates from either result, but either way, that still requires calculating the full list of nonunique results as an intermediate step, which I expect to be many orders of magnitude longer than the unique results.

Is it possible to get the result I’m after without having to cull a humongously longer list first to get there?