Given an alphabet A = {a,b,c,d,...}
of length n, I would like to get all permutations of length r (r < n).
Now I would like to number these permutations, and there should be a reverse mapping.
For example:
A = {a,b,c}, r = 2
ab -> 0
ba -> 1
ac -> 2
ca -> 3
...
How can I achieve this? I have found it for problems which are order-invariant. But I cant apply it to this situation with the order.
Is there some library doing it in python?