TITLE: What are the no of ways in which we can place 7 apples in 5 containers, given neither apples nor containers are identical.
QUESTION [6 upvotes]: What are the no of ways in which we can place $7$ apples in $5$ containers such that each container contains at least $1$ apple, given neither apples nor containers are identical
My attempt is as follows:
As containers are not identical, so let's enumerate them as $C_1,C_2,C_3,C_4,C_5$ and as apples are not identical, so let's enumerate them as $A_1,A_2,A_3,A_4,A_5,A_6,A_7$
Now let's try to fill one apple in all the $5$ containers.
No of ways to fill one apple in container $C_1=7$
No of ways to fill one apple in container $C_2=6$
No of ways to fill one apple in container $C_3=5$
No of ways to fill one apple in container $C_4=4$
No of ways to fill one apple in container $C_5=3$
Let's multiply all of them to get the no of ways in which we can fill $1$ apple in each of the container$=7\cdot6\cdot5\cdot4\cdot3=2520$
Now in each of the $2520$ ways, $2$ apples will be left at the end, now as all the containers are containing at least one apple, we can put the remaining $2$ apples in any of the containers. 
So no of ways to place remaining $2$ apples in any of the containers$=5\cdot5=25$
So $2520\cdot25=63000$ should be the answer.But actual answer is $11760$.
Where am I making the mistake. I tried to find it but didn't get any breakthroughs.

REPLY [4 votes]: We start with OPs approach:

The first part, namely putting five apples one into each container in $\frac{7!}{2!}=2\,520$ different ways is quite ok.

The second part has to be reconsidered. Let's WLOG assume there are $(A_1,A_2,A_3,A_4,A_5)$ in the five container $(C_1,C_2,C_3,C_4,C_5)$ and we want to distribute $A_6$ and $A_7$ into one or two container.

Case (a): $A_6, A_7$ distributed into two different container. We have the situation



\begin{align*}
&\color{blue}{C_1\qquad C_2\qquad C_3\qquad C_4\qquad C_5}\\
&A_1\qquad A_2\qquad A_3\qquad A_4\qquad A_5\tag{1}\\
&A_6\qquad A_7
\end{align*}

We observe we get the same constellation (1) when in the first part $(A_6,A_2,A_3,A_4,A_5)$ were distributed into the five container $(C_1,C_2,C_3,C_4,C_5)$ and we then put $A_1$ into $C_1$ and $A_7$ into $C_2$. In the same way we can exchange $A_2$ with $A_7$ to also obtain the same constellation (1).
This means we have $\color{blue}{2\cdot 2=4}$ cases to identify.


Case (b): $A_6, A_7$ put into the same container. Here we have the situation

\begin{align*}
&\color{blue}{C_1\qquad C_2\qquad C_3\qquad C_4\qquad C_5}\\
&A_1\qquad A_2\qquad A_3\qquad A_4\qquad A_5\tag{2}\\
&A_6\\
&A_7\\
\end{align*}

We observe that we obtain the same constellation (2) when we have in the first part $(A_6,A_2,A_3,A_4,A_5)$ distributed into the five container $(C_1,C_2,C_3,C_4,C_5)$ and then put $A_1$ and $A_7$ into $C_1$. Here we can exchange $A_1$ with $A_6$ or $A_7$ to also obtain the same constellation (2).
This means we have $\color{blue}{3\cdot 1=3}$ cases to identify.

Conclusion: The $5\cdot 5=25$ cases are subdivided as follows:

There are $2\binom{5}{2}=20$ ways to select two different container out of the five container and we have to identify four cases as we are in part (a).

There are $\binom{5}{1}=5$ ways to select one container out of the five container and we have to identify three cases as we are in part (b).

We finally obtain
\begin{align*}
  2\,520\cdot \frac{20}{4}+2\,520\cdot \frac{5}{3}&=12\,600 + 4\,200\\
  &\,\,\color{blue}{=16\,800}
\end{align*}
ways to put 7 distinguishible apples into 5 distinguishible container.



Algebraic method:
Here is a generating function approach. Denoting with $[x^n]$ the coefficient of $x^n$ of a series and recalling that $e^x$ is the generating function for counting configurations with labelled objects,

we obtain
\begin{align*}
  \color{blue}{7![x^7]\left(e^x-1\right)^5}&=7![x^7]\left(x+\frac{x^2}{2!}+\frac{x^3}{3!}\right)^5\tag{3}\\
   &=7![x^7]x^5\left(1+\frac{x}{2}+\frac{x^2}{6}\right)^5\tag{4}\\
   &=7![x^2]\sum_{j=0}^5\binom{5}{j}\left(\frac{x}{2}+\frac{x^2}{6}\right)^j\tag{5}\\
   &=5\,040\left(\binom{5}{1}\cdot\frac{1}{6}+\binom{5}{2}\cdot\left(\frac{1}{2}\right)^2\right)\tag{6}\\
%    &=5\,040\left(5\cdot\frac{1}{6}+10\cdot\frac{1}{4}\right)\\
    &\,\,\color{blue}{=16\,800}
  \end{align*}

Comment:

In (3) we take powers of $x$ up to $x^3$ since higher powers do not contribute to $[x^7]$. This corresponds to a maximum of three apples in a container.

In (4) we factor out $x^5$.

In (5) we apply the rule $[x^p]x^qA(x)=[x^{p-q}]A(x)$ and expand the binomial.

In (6) we select the terms which contribute to $[x^2]$.


Note: The number $11\,760$ seems to be an answer to a different question.