# Number of ways to pack K items into N bins each with capacity R

I am trying to figure the number ways you can pack K items into N bins where all bins have a uniform capacity of R.

For instance, lets say you have 3 items and 4 bins, where each bin has a capacity of 2.

One possible arrangement shown here

Does anyone know how to calculate this number of combinations? I am familiar with combinations with repetition but I'm not sure about the case where all bins have the same capacity R. I have seen some similar posts but couldn't find any with this problem setup.

• 1. Are the K items identical or distinct ? 2. Are the bins numbered or indistinguishable ? Sep 16, 2022 at 7:42
• Assuming that the $K$ items are identical and that the bins are numbered, you are looking for the number of non-negative integer solutions to $x_1 + x_2 + \cdots + x_n = K$, where $x_1,x_2, \cdots,x_n$ are all required to be $\leq R$. Under this interpretation, the posted problem is covered by this answer, which answers a more general question. Sep 16, 2022 at 7:47
• The items are distinct, and the bins are numbered. This is related to a networking problem. In this case the K items are each a software program which has a failure probability. Each of the N bins are a server which has some failure probability. Because each entity has its own failure probability, both the items and the bins are distinct. Sep 16, 2022 at 22:28
• Clarification requested. Given that the both the items and the bins are distinct, suppose that Item-1 and Item-2 both go into Bin-1. Is the case where item-1 goes first and then item-2 goes next considered distinct from the case where item-2 goes first and item-1 goes next? If so, that greatly simplifies the problem, because you can take the enumeration from my first comment and simply apply the (overall) factor of $K!$. If not, then I think that my entire approach is problematic and that (therefore) a different approach is needed. Sep 19, 2022 at 6:32
• Thanks for your input. No, if item-1 and item-2 both go into the same bin, then the order in which they are placed in the bin does not matter, they are not distinct. Yeah it looks like the solution in the link you posted will work. Sep 19, 2022 at 15:55

There would need to be a listing of patterns possible, multiplied by their permutations and placement choices, e.g. for $$6$$ distinct items in $$5$$ distinct bins with a maximum of $$2$$ in a bin,
• possible patterns are $$22200\;22110\;21111$$
• their permutations are $$\large\frac{5!}{3!2!}\, \large\frac{5!}{2!2!1!} \;and\; \large\frac{5!}{1!4!}$$
• and placements are $$\large\frac{6!}{2!2!2!}\,, \large\frac{6!}{2!2!}\;and\; \large\frac{6!}{2!}$$
• Final results $$10\cdot90+30\cdot180+5\cdot360$$