# Re: Permutations to scalars and back again.

```On 9/12/2016 8:01 PM, Georgi Guninski wrote:
```
```On Mon, Sep 12, 2016 at 07:50:50PM +1000, James A. Donald wrote:
```
```To restate the problem:  Find a mapping between integers and injective
functions from N to X up to a permutation of N.```
```
In this case, find a mapping between integers and an injective functions
from 18 to 36.
```
```
Sage (open source, sagemath.org) can do at least parts of what you
Not sure I get the question about injective function, but AFAICT
treating the permutation as nonnegative integer in binary will do.

Example sage session:

sage: l=[0]*2+[1]*2
sage: pe=Permutations(l)
sage: pe.cardinality()
6
sage: pe[0]
[0, 0, 1, 1]
sage: for p in pe:  print p
[0, 0, 1, 1]
#...more

```
```

Found the the solution.

Combinatorial number system.

```
Suppose we have k cards, any one of which can be white or red, but which are otherwise indistinguishable and interchangeable.
```
```
Combinatorial number system gives us a one to one mapping between integers, and all possible subsets of an n element set.
```
```
Now I want a mapping between integers and all possible m element subsets of an n element set, but for m approximating n/2 the mapping is dense enough to be useful.