Function Repository Resource:

SubsetFromIndex

Get the subset with the given index and length

Contributed by: Ed Pegg Jr
 ResourceFunction["SubsetFromIndex"][index,len] returns a subset of length len with given index.

Details and Options

Subsets are considered to be lists {a1,a2,,ak} such that the ai are non-negative integers and strictly increasing.
Subsets are sorted by their reverse; {1,2,3} comes before {0,1,4}.
For any subset, a unique index n can be defined via .
For example: subset {2,4,6} has index .

Examples

Basic Examples (3)

Give the first ten 3-subsets:

 In[1]:=
 Out[1]=

The following code gives the same 3-subset sequence:

 In[2]:=
 Out[2]=

The function can return subsets of a large index:

 In[3]:=
 Out[3]=

The function can return the subset of a given index for various lengths:

 In[4]:=
 Out[4]=

Scope (3)

Some binomial representations of the number 320:

 In[5]:=
 Out[5]=

Here are some 2-subsets with their indices to show their structure:

 In[6]:=
 Out[6]=

The structure of 3-subsets in 3D:

 In[7]:=
 Out[7]=

Neat Examples (1)

Find the trillionth numbers with binary weights eight to twelve:

 In[8]:=
 Out[8]=

Version History

• 2.0.0 – 24 December 2019
• 1.0.0 – 05 December 2019