This question already has an answer here:

Suppose we have $R$ containers ($x_1,x_2,\ldots,x_R$) and we have $N$ balls. How many possible distributions we have assuming that $x_{min}\leq x_r\leq x_{max}$ $\forall r\in\{1,2,\ldots,R\}$?

The following is my current work to solve this problem:

Dropping the minimum and maximum constraint, we have


with $x_r\geq0$. We have $\binom {N+R-1}{R-1}$ possible combinations [Reference]

For the minimum constraint, we can define $y_r=x_r-x_{min}$. Therefore, we have


with $y_r\geq0$ meaning that $x_r-x_{min}\geq0$ meaning that $x_r\geq x_{min}$. Therefore, we have $\binom {N-R*x_{min}+R-1}{R-1}$ possible combinations.

I am stuck at applying the maximum constraint. Can someone help with applying the maximum constraint?

I do appreciate your help. Thank you


marked as duplicate by Brian M. Scott combinatorics Jan 2 '17 at 4:15

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

  • 1
    $\begingroup$ It gets messy; Marc’s answer to the the earlier question is probably about as good an answer as you’re going to be able to get. $\endgroup$ – Brian M. Scott Jan 2 '17 at 4:16
  • $\begingroup$ Thank you very much @BrianM.Scott $\endgroup$ – Unknown Jan 2 '17 at 4:32
  • 1
    $\begingroup$ You’re very welcome. $\endgroup$ – Brian M. Scott Jan 2 '17 at 4:43