Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Ranks k-composites that sum to n
def gam_to_lam(c, n):
i, m = 0, 0
L = [0] * n
while 1:
i = i+1
if c[i-1] > 0:
for j in range(1, c[i-1] + 1):
m = m + 1
L[m-1] = i
if m == n: return L
def lam_to_k(L, n):
K = [0] * n
for i in range(0, n):
K[i] = L[i] + i
return K
def rank_combination(a, k, n):
r = 0
for j in range(1, k+1):
r += binomial(n - a[j-1], k - j + 1)
return r
def rank_class(a, k, n):
c = gam_to_lam(a, n)
c = lam_to_k(c, n)
r = rank_combination(c, n, n+k-1)
return r
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.