Find index of an ordered set of $N$ elements

66 Views Asked by At

Problem description: A set of lists of $N$ integers $i_1,i_2,\ldots,i_N$ with $0\le i_1\le i_2\le i_3\le\ldots\le i_N\le M$, is created by starting with one integer $0\le i_1\le M$, and repeatedly adding one integer that is greater or equal to the last integer added. When adding the last integer to get the final set of lists, the index runs starting from 0 to BinomialC[M+N,N)]-1.

For example, for M=3, i1=0,1,2,3 

so the lists are

{0},{1},...,{3}. 

Adding another integer $i_2\ge i_1$ will result in

{0,0},{0,1},{0,2},{0,3},
{1,1},{1,2},{1,3},
{2,2},{2,3}
{3,3}

with indices

0,1,2,3,
4,5,6,
7,8,
9.

This index can be represented in terms of $i_1,i_2,\ldots,i_N$ and $M$. If the conditions $\ge$ were not present, then it would be simply $i_1\cdot(M+1)^{N-1}+i_2\cdot(M+1)^{N-2}+\cdots+i_N\cdot(M+1)^{N-N}$. But, in the case above, there is a negative shift in the index due to the restrictions. For example, N=2 the shift is $-\frac{i_1(i_1+1)}2$ and index is $i = i_1\cdot(M+1)^1 + i_2\cdot(M+1)^0 -\frac{i_1(i_1+1)}2$.

Question: Does anyone especially from mathematics background knows how to write the index for general N element case? or just the final expression? Any help would be appriciated! Thanks!