(Re-posting, as I did not get any response to my previous post)
I am trying to write a Python code to generate weak integer compositions (partitions) of a number 'n' into 'k' parts but with a MINIMUM and MAXIMUM value constraint on each partition (see example given below). Also, the partitions have to be generated in lexicographic order. I have found some related posts but have not been able to implement it. Any help will be appreciated.
Example:
Possible integer partitions for n=5 in k=3 parts:
[5,0,0], [4,1,0], [4,0,1], [3,2,0], [3,1,1], [3,0,2], ..., [0,0,5]
After imposing the constraint that each integer in the partition has a MINIMUM value 0 and a MAXIMUM value 3, I should get:
[3,2,0], [3,1,1], [3,0,2], ...so on, only.
Related posts:
Elegant Python code for Integer Partitioning
Generate lexicographic series efficiently in Python