Counting ways to put objects(balls) in a row with some restrictions So i have $n$ white balls(let's mark them W), $m$ red balls(R) and $k$ black balls(B).
So i want to count how many ways there are to put all the balls in a row if you follow restrictions $(1)$ or $(2)$
(1)first red ball is befroe first black ball, every white ball is followed by either red either black ball.
(2) first red ball is before last white ball, two black balls will never be together.
So i thought that i could solve by just counting with permutations/combinations etc.
But i got stuck because of problem with representing it.
Any help would be appreciated.
 A: For the first one, let’s ignore the white balls for a moment. There are $\binom{m-1+k}k$ ways to arrange $m-1$ red and $k$ black balls, so there are also $\binom{m-1+k}k$ ways to arrange $m$ red balls and $k$ black balls so that a red ball is first. The $n$ white balls must now be inserted into this string of $m+k$ balls in such a way that each of them is immediately followed by a red or a black ball. This means that they must go into the $m+k$ slots before the first red ball or between adjacent red and black balls, and only one white ball can go into any of those slots. Thus, there are $\binom{m+k}n$ ways to choose positions for the white balls and therefore
$$\binom{m-1+k}k\binom{m+k}n$$
possible arrangements altogether.
The second problem is actually a little simpler. Requiring that the first red ball precede the last white ball rules out only one arrangement of the red and white balls, namely, the one in which all $n$ white balls precede all $m$ red balls. Thus, there are $\binom{n+m}n-1$ possible arrangements of the red and white balls. The $k$ black balls must now be inserted into the $n+m+1$ slots before the first of the red and white balls, between adjacent red and white balls, or after the last of the red and white balls. Again we can put at most one black ball into each slot, so there are $\binom{n+m+1}k$ ways to insert the black balls into the string and therefore
$$\left(\binom{n+m}n-1\right)\binom{n+m+1}k$$
arrangements altogether.
