For positive integers n and k, let a "k-partition of n" be a sorted list of k distinct positive integers that add up to n, and let the "rank" of a given k-partition of n be its position in the sorted list of all of these lists in lexicographic order, starting at 0.
For example, there are two 2-partitions of 5 (n = 5, k = 2): [1,4] and [2,3]. Since [1,4] comes before [2,3] in lexicographic order, the rank of [1,4] is 0 and the rank of [2,3] is 1.
So, I want to be able to do two things:
- Given n, k, and a k-partition of n, I want to find the rank of that k-partition of n.
- Given n, k, and a rank, I want to find the k-partition of n with that rank.
Can I do this without having to compute all the k-partitions of n that come before the one of interest?
This question is different from other because we are here talking about integer partitions and not just combinations.