Function Repository Resource:

# OrderlessCombinations

Generate all possible orderless lists of a given length with a given set of elements

Contributed by: Jon McLoone
 ResourceFunction["OrderlessCombinations"][list,n] gives all possible orderless sets comprised of the elements of list up to length n. ResourceFunction["OrderlessCombinations"][list,{n}] gives sets of exactly length n. ResourceFunction["OrderlessCombinations"][list,{n,m}] gives sets containing between n and m elements.

## Examples

### Basic Examples (2)

There are nine possible orderless sets of up to two elements chosen from three possible elements:

 In[1]:=
 Out[1]=

There are six possible orderless sets of exactly two elements chosen from three possible elements:

 In[2]:=
 Out[2]=

### Scope (2)

Get length four sets from a list of length two:

 In[3]:=
 Out[3]=

Elements need not be integers:

 In[4]:=
 Out[4]=

### Applications (1)

A company makes three different heating units. The customer needs a row of five heating units for a large room. How many different purchase combinations are available to the customer:

 In[5]:=
 Out[5]=

### Properties and Relations (1)

The same sets can be generated by sorting and deduplicating the output of Tuples, but OrderlessCombinations is faster, and uses much less memory for larger problems:

 In[6]:=
 Out[6]=
 In[7]:=
 Out[7]=

Jon McLoone

## Version History

• 1.0.0 – 25 October 2022