Exhaustive list of ways to distribute n objects to k sets
The objects you are interested in enumerating are counted by Stirling numbers of the second kind. In particular, $\genfrac{\{}{\}}{0pt}{}{n}{k}$ is the number of ways to partition a set of size $n$ into $k$ non-empty parts. The Stirling numbers satisfy the recurrence
$$
\genfrac{\{}{\}}{0pt}{}{n+1}{k} = k\genfrac{\{}{\}}{0pt}{}{n}{k} + \genfrac{\{}{\}}{0pt}{}{n}{k-1}.
$$
Indeed, either element $n+1$ is in a partition of its own, or it joins one of the other $k$ parts. The initial conditions are $\genfrac{\{}{\}}{0pt}{}{0}{0} = 1$ and $\genfrac{\{}{\}}{0pt}{}{0}{n} = \genfrac{\{}{\}}{0pt}{}{n}{0} = 0$ for $n &gt; 0$. In other words, if $n = k = 0$ then there is a unique solution (the trivial solution), and if $n = 0$ or $k = 0$ otherwise then there are no solutions.

You can use this recurrence to recursively generate all partitions you are after.