There are three choices for each of the five balls. Hence, if there were no restrictions, the balls could be placed in the boxes in $3^5$ ways. From these, we must exclude those distributions in which one or more of the boxes is empty.
There are $\binom{3}{1}$ ways to exclude one of the boxes and $2^5$ ways to distribute the balls to the remaining boxes. Hence, there are
$$\binom{3}{1}2^5$$
ways to distribute the balls so that one of the boxes is empty.
However, we have counted those distributions in which two of the boxes are empty twice, once for each of the ways we could have designated one of the empty boxes as the excluded box. We only want to exclude them once, so we must add these cases back.
There are $\binom{3}{2}$ ways to exclude two of the boxes and one way to place all the balls in the remaining box.
Hence, the number of ways the balls can be distributed so that no box is left empty is
$$3^5 - \binom{3}{1}2^5 + \binom{3}{2}1^5$$
by the Inclusion-Exclusion Principle.
Where am I going wrong?
You count each distribution in which one box receives three balls and the others receive one three times, once for each way you could place one of those three balls first.
You count each distribution in which two of the boxes receive two balls and the other box receives one four times, once for each way you could place one of the two balls in each of the two boxes with two balls first.
Three balls in one box and one ball in each of the others: There are three ways to choose which box receives three balls, $\binom{5}{3}$ ways to choose which three balls are placed in that box, and $2!$ ways to distribute the remaining balls. Hence, there are
$$\binom{3}{1}\binom{5}{3}2!$$
ways to distribute the balls so that three balls are placed in the same box.
Two boxes receives two balls and one box receives one ball: There are three ways to choose which box receives only one ball and five ways to choose the ball that is placed in that box. There are $\binom{4}{2}$ ways to choose which two of the remaining four balls are placed in the smaller of the two remaining boxes. The other two balls must be placed in the remaining box. Hence, there are
$$\binom{3}{1}\binom{5}{1}\binom{4}{2}$$
ways to distribute the balls so that two boxes receive two balls and one box receives one.
Observe that
$$\binom{3}{1}\binom{5}{3}2! + \binom{3}{1}\binom{5}{1}\binom{4}{2} = 3^5 - \binom{3}{1}2^5 + \binom{3}{2}1^5$$
Since you counted distributions in which one box receives three balls and the others receive one three times and distributions in which two boxes receive two balls and the other receives one four times, you obtained
$$3\binom{3}{1}\binom{5}{3}2! + 4\binom{3}{1}\binom{5}{1}\binom{4}{2} = \binom{5}{3} \cdot 3! \cdot 3^2$$
In how many ways can we distribute $10$ indistinguishable balls to $4$ different boxes such that no box receives exactly three balls?
Your strategy is correct. However,
$$\binom{13}{10} - \binom{4}{1}\binom{9}{7} + \binom{4}{2}\binom{5}{4} - \binom{4}{3}\binom{1}{1} = 286 - 144 + 30 - 4 = 168$$
In how many ways can we distribute $10$ different balls to $4$ different boxes such that no box has exactly three balls?
What you have done so far is correct.
There are four ways to distribute each of the $10$ balls, so there are $4^{10}$ ways to distribute the balls without restriction.
From these, we must subtract those cases in which one or more of the boxes receives exactly three balls.
A box receives exactly three balls: There are four ways to select the box which receives exactly three balls, $\binom{10}{3}$ ways to select which three balls that box receives, and $3^7$ ways to distribute the remaining seven balls to the remaining three boxes. Thus, there are
$$\binom{4}{1}\binom{10}{3}3^7$$
such distributions.
Two boxes each receive exactly two balls: There are $\binom{4}{2}$ ways to select which two boxes receive exactly three balls, $\binom{10}{3}$ ways to select which three balls are placed in the leftmost of those boxes, $\binom{7}{3}$ ways to select which three of the remaining seven balls are placed in the other box which is selected to receive exactly three balls, and $2^4$ ways to distribute the remaining four balls to the remaining two boxes. Hence, there are
$$\binom{4}{2}\binom{10}{3}\binom{7}{3}2^4$$
such distributions.
Three boxes each receive exactly three balls: There are $\binom{4}{3}$ ways to select which three boxes receive exactly three balls, $\binom{10}{3}$ ways to select which three balls are placed in the leftmost of those boxes, $\binom{7}{3}$ ways to select three of the remaining seven balls is placed in the middle of those boxes, $\binom{4}{3}$ ways to select which three of the remaining four balls is placed in the rightmost of those boxes, and one way to place the remaining ball in the remaining box. Hence, there are
$$\binom{4}{3}\binom{10}{3}\binom{7}{3}\binom{4}{3}1^1$$
such distributions.
By the Inclusion-Exclusion Principle, the number of ways ten distinct balls can be distributed to four distinct boxes so that no box receives exactly three balls is
$$4^{10} - \binom{4}{1}\binom{10}{3}3^7 + \binom{4}{2}\binom{10}{3}\binom{7}{3}2^4 - \binom{4}{3}\binom{10}{3}\binom{7}{3}\binom{4}{3}1^1$$
Best Answer
What you have done is correct.
You can apply Principle of Inclusion Exclusion and that leads to the same answer.
Using P.I.E, ${50 \choose 2} \times \sum \limits_{i=0}^{48} {(-1)^i} {48 \choose i} (48-i)^{50}$
Another way to do it will be to choose $2$ empty boxes out of $50$ and then use Stirling Number of the second kind to make $48$ non-empty heaps from $50$ balls and then permute the heaps as we have distinct boxes. That again leads to the same answer.
$S2(50,48) \times 48! \times {50 \choose 2}$
Here is the answer when you calculate any of the above $3$ expressions using Mathematica - $10804606609908677549993379050994509131965157167373221888000000000000000$