Artificial intelligent assistant

Dividing n stones into x piles of size greater than q but less than r Perhaps this is a basic question, but I'm having a hard time figuring out a general form for the solution. Consider a pile of indistinguishable stones of size **n**. How many ways can the pile of **n** stones be divided into **x** piles of size greater than **q** but less than **r** if the order of the piles does not matter? How does this answer change if the order of the piles does matter? Thanks in advance for the help!

If each pile is going to have more than $q$ stones, you might as well set aside $qx$ stones ahead of time in which to distribute $q$ to each pile; there is no choice involved in that procedure. The only choices left are how to distribute $n-qx$ stones to $x$ locations in which each pile has at least $1$ stone but less than $r-q$ stones. If the piles are ordered, respectively unordered, this amounts to counting integer partitions, respectively integer compositions, of $n-qx$ into $x$ parts each of size $
Using generating functions, these counts are given respectively by

$$[t^x w^{n-qx}]\left(\frac{w}{1-tw}\frac{w^2}{1-tw^2}\cdots\frac{w^{r-q-1}}{1-tw^{r-q-1}}\right), \qquad [w^{n-qx}]\left(\frac{w^{r-q}-w}{w-1}\right)^x.\quad$$

I doubt the first has a nice explicit form. Via Newton-Binomial expansion, the second is

$$(-1)^{n-(q+1)x}\sum_{t=0}^x (-1)^{(r-q)t}\binom{x}{t}\binom{-x}{n-(q+1)x-(r-q-1)t}.$$

xcX3v84RxoQ-4GxG32940ukFUIEgYdPy 2b51d540130b0319fb7e4618e057d860