Splitting a positive integer n is a non-increasing array of positive integers
a [1], a [2], ..., a [m]
satisfying
a [1] + a [2] + ... + a [m] = n.
m is called the length of this section.
We can list all sections of n in that order. For example, if we use the rule by which lexicography sorts all English words, it is called the lexicographic order. Another way, if we use the rule by which the C language compares strings, is called reverse lexicography order. And there is also colex order.
To generate all sections of the integer n, we have a good algorithm proposed by Stojmenovic, which is already included in Knuth's book.
To generate all sections of n with exactly m length, we can use colex ordering; this algorithm is also included in the Knuth book.
In order to generate all sections of n with all their elements not exceeding k, we can use the algorithm in 1 by simply changing its initial condition and the condition for the loop to exit.
Here is my question: how to generate those sections whose length is exactly equal to m, and their elements do not exceed k?
Here m and k are constants. Of course, a partition with its elements not exceeding k is equivalent to its first element not exceeding k.
Oh, I think I solved it. for
a [1] + a [2] + ... + a [m] = n
can be written as
(k + 1-a [1]) + (k + 1-a [2]) + ... + (k + 1-a [m]) = m (k + 1) -n
and the last is just the inverse partition of m (k + 1) -n!