Let N be the number of ways to arrange four black balls, four white balls, and two red balls in a row, so that for each color, not all the balls of that color are consecutive. (For example, if B, W, and R represent a black, white, and red ball, respectively, then the arrangement WRWWRBBBBW is not allowed, because all the black balls are consecutive.) Find the remainder when N is divided by 1000. Many cases blew my head off.(first all black, then white, then red, then two together-3 cases and then all three together…)
[Math] 10 Balls in a row (4B 4W 2R), with not all balls of any color consecutive
combinatorics
Related Solutions
We can consider each configuration for without replacement as a sequence of balls. Then permuting the sequence in any way gives another configuration with equal probability because every sequence has equal probability. Each permutation can be used to give a bijection (one-to-one correspondence) between a set of configurations with another that differ simply by that permutation.
For example, in the first question you want #(sequences with 5th ball red)/#(sequences), and #(sequences with 5th ball red) = #(sequences with 1st ball red) by the bijection that switches the 1st and 5th ball in a sequence. Check that every sequence with 5th ball red corresponds to exactly one sequence with 1st ball red, and vice versa. This gives the answer since #(sequences with 1st ball red)/#(sequences) = 3/9 because there are no restrictions on the later balls.
For the second question, to do it rigorously we choose some permutation that sends the 3rd ball to position 1, the 7th ball to position 2 and the 9th ball to position 3. Then we get #(sequences with 3rd and 7th ball red and 9th ball black) = #(sequences with 1st and 2nd ball red and 3rd ball black), and #(sequences with 3rd and 7th ball red) = #(sequences with 1st and 2nd ball red). So the answer is #(sequences with 1st and 2nd ball red and 3rd ball black)/#(sequences with 1st and 2nd ball red) = 2/7 since the first two balls already use up two red and after drawing the first two we are left with 7 balls of which 2 are black.
Here is a recursive method:
Let $P(n)$ denote the answer for a string of length $n$ . We remark that $$n≤3\implies P(n)=1 \quad \&\quad P(4)=1-\left(\frac 23\right)^4$$
For $n>4$ we remark that if a sequence is good then it must begin with exactly one of $B,WB,W^2B,W^3B$ and of course it must then be followed by a good sequence of shorter length. It follows that $$P(n)=\frac 13\times P(n-1)+\frac 23\times \frac 13\times P(n-2)+\left( \frac 23\right)^2\times \frac 13\times P(n-3)+\left( \frac 23\right)^3\times \frac 13\times P(n-4)$$
This is very easy to implement mechanically, maybe a bit slow to do with pencil and paper.
We get $$P(5)=0.736625514,\quad P(6)=0.670781893,\quad\boxed {P(7)=0.604938272}$$
Sanity Check: Let's get $P(5)$ by hand. The only "bad" sequences of length $5$ are $W^4B, BW^4, W^5$. Easy to compute the probabilities of each and we get $$P(5)=1-2\times \left(\frac 23\right)^4\times \frac 13-\left( \frac 23 \right)^5=0.736625514$$ which matches the result obtained by the recursion.
Best Answer
We will compute the answer by inclusion exclusion.
The total number of ways to arrange the 10 balls is given by $\frac {10!}{4! 4! 2!} = 3150$. These include arrangements that violate the conditions so we need to remove them.
We first remove the cases where all black are consecutive. To count the number of such arrangements imagine merging all black balls into one segment, so in total we have $\frac {7!}{1! 4! 2!} = 105$ ways of arranging the 4 white balls, the 2 red balls and the black segment. Similarly, work for the case where all white balls or red are consecutive and subtract $105$ and $630$ respectively.
By subtracting the above we double-counted the cases where balls of two or more colors are consecutive at the same time and we need to add them back. First, we need to include back the cases where both the white balls and the black balls are consecutive. These are in total $\frac {4!}{1! 1! 2!} = 12$ cases. We do the same for black and red, and white and red to add $\frac {6!}{4! 1! 1!} = 30$ and $\frac {6!}{ 1! 4! 1!} = 30$ cases respectively.
Finally, we need to subtract the number of ways to arrange balls of all colors consecutively which is exactly $\frac {3!}{ 1! 1! 1!} = 6$ ways. So in total we have $3150 - 105 - 105 - 630 + 12 + 30 + 30 - 6 = 2376 \equiv376\pmod{1000}$