# Get a fixed-size family of k-element subsets

I have an n-element set, and I want to consider families of its k-element subsets of fixed size s. For example, if n = 3, k = 1, s = 2, we have these families:

{{1}, {2}}, {{1}, {3}}, {{2}, {3}}


In my problem n, k, s are not so small, e.g. s = n = 50, k = 20.

Let us say all such families are ordered lexicographically (or really in any clearly stated order). I want to have an efficient way to get a family by its number.

I have only a following idea: enumerate all k-element subsets of n-element set (there is an efficient algorithm to get i-th element by i). Then enumerate all s-element subsets of comb(n, k)-element set, using the same operation. Now we need to generate a number in range (0, comb(comb(n, k), s)) and turn it firstly to the number of s-element subset and then to a family of k-elements sets.

However, I want to know, if there is a more beautiful approach than just generating first combination and then second combination by its numbers.

In general, what you are looking for is a combinatorial number system (of degree $t$) , i.e., a correspondece between $\mathbb{N}$ and all $t$-combinations.
There is a large number of algorithms for $t$-combination generation from the last (at least) 50 years. In particular, the operations you are interested in are typically called rank and unrank.