I need an algorithm that produces a partition of the number n
into k
parts with the added restrictions that each element of the partition must be between a
and b
. Ideally, all possible partitions satisfying the restrictions should be equally likely. Partitions are considered the same if they have the same elements in different order.
For example, with n=10
, k=3
, a=2
, b=4
one has only {4,4,2}
and {4,3,3}
as possible outcomes.
Is there a standard algorithm for such a problem? One can assume that at least one partition satisfying the restrictions always exists.