title: Enumerate all possible distributions of n balls into k boxes
body: <p>The exact problem i am referring to and the number of distributions for the  problem is computed <a href="https://math.stackexchange.com/a/1441337/184201">here</a>. I am interested in knowing those distributions explicitly.</p>
  
  <p>For example, there are 5 balls and 3 boxes: one distribution is 2 balls in box 1, 2 in box 2, 1 in box 3 referred to as, say 221. Now i want to list all such possible distributions: -</p>
  
  <p>212</p>
  
  <p>131</p>
  
  <p>104</p>
  
  <p>.
  .
  .</p>
  
  <p>One way is that i run the matlab command: <code>perms([0,0,0,0,0,1,1,1])</code>. This essentially generates all permutations of 5 balls and 2 sticks. but there is massive over-counting as the command <code>perms</code> does not recognize identical objects.</p>