Let n
and m
be natural numbers. Then, how does one write a function ordint[n,m]
that gives every $2n$ integers ${a_1,...,a_n,b_1,...,b_n}$ such that $0\leq a_1$, $a_i < a_j$ if $i < j$, $a_n \leq b_1$, $b_i < b_j$ if $i < j$, and $b_n \leq m$? For example, the following ordint2[m]
gives the desired output for n=2
.
ordint2[m_]:=Module[{S,A,B},
S={};
Do[S=Append[S,{A[1],A[2],B[1],B[2]}],
{B[2],0,m},{B[1],0,B[2]-1},{A[2],0,B[1]},{A[1],0,A[2]-1}];
S]
But, I do not know how to implement the varying index condition
{B[n],0,m},{B[n-1],0,B[n]-1},....,{B[1],0,B[2]-1},{A[n],0,B[1]},{A[n-1],0,A[n]-1},...,{A[1],0,A[2]-1}
to write ordint[n,m]
for a general n.