How one might write a function (in Python) that:
If we take all the permutations for A, B and C: ABC, ACB, BAC, BCA, CAB, CBA
The function would take an index and return the permutation for that index.
E.g. F("ABC", 4) would return "BCA"
It should run in a reasonable time for very large permutation sets.