Let $x_1,\dots,x_m$ be non-negative integers such that $\sum_{i=1}^m x_i=n$, where $m,n$ are given. How can I enumerate all such lists of $m$ integers that add to $n$?
Note that IntegerPartitions[n,{m}] counts two such lists as one if they are a permutation of each other, but I would count them as distinct.
Thus the list I want must have $\binom{m+n-1}{m-1}$ elements.
Apply[Sequence]@*Permutations /@ IntegerPartitions[n, {k}]– AccidentalFourierTransform Sep 24 '18 at 15:37FrobeniusSolve[ConstantArray[1, m], n]. (I am sure this is a dupe.) – J. M.'s missing motivation Sep 24 '18 at 15:38Permutationsconsidered repeated elements as identical. Feel free to post an answer. – a06e Sep 24 '18 at 15:42Apply[Sequence]@*Permutations /@ (IntegerPartitions[n + k, {k}] - 1)– a06e Sep 24 '18 at 15:52