How many ways are there to arrange 4 indistinguishable apples and 4 indistinguishable pears in a row so that each apple is next to at least one pear?
bonus points if you can get it - have fun 2.0ers! - proyaop
Scroll down to see answer, very long.
I'll give this my best attempt
We see that without the condition, the number of total possibilities of arranging the indistinguishable fruits is \(\frac{8!}{4!4!}=70\).
Now add this condition in, and we need to find the total number of cases that don't satisfy this condition, or otherwise that there is at least one instance of an apple that is surrounded by apples.
Lets split that into 3 sub-conditions
Condition 1) An apple is first and the second fruit is also an apple
Condition 2) An apple is last and the second to last fruit is also an apple
Condition 3) An apple is not first or last, but the two fruits next to it are apples. (3 apples in a row)
Now we have lots of cases to consider.
Satisfying condition 1, we have \(\frac{6!}{4!2!}=15\) cases for condition 1.
Satisfying condition 2, we also have \(\frac{6!}{4!2!}=15\) cases for condition 2.
Condition 3 is more difficult, because 3 apples in a row, also includes 4 apples in a row, but we overcount, the cases for 4 apples in a row.
First we count the cases for 3 apples which, we treat 3 apples a group, or a seperate variable, so we order the group, one apple, and 4 pears getting \(\frac{6!}{4!1!1!}=30\), but we overcount many cases with 4 apples in a row. Each case with 4 apples in a row can be formed 2 ways, for example consider the sequence PAAAAPPP where P is pear and A is apple. This sequence can be formed by P + AAA +APPP or also PA + AAA+PPP with our counting, so we count each 4 in a row case twice, so we need to subtract once the cases with 4 in a row.
Again, to count the number of 4 in a row cases, we treat the 4 as a group, a seperate item, so there is a total of \(\frac{5!}{4!1!} = 5\) 4 in a row cases. Subtracting this, we get \(30-5=25\) total cases for condition 3.
Now we count the overlaps. We see that there is 1 case of condition 1 and condition 2, AAOOOOAA.
We see there is 5 cases of condition 1 and condition 3. AAA + an A in any of the 5 remaining spaces, yields 5 cases.
We see there is also 5 cases of condition 1 and condition 3. an A in any of the first 5 spaces + AAA, yields an additional 5 cases.
We see there is not possible a case of condition 1 and condition 2 and condition 3, because after AAOOOOAA we can't satisfy condition 3.
So now we have. \(15+15+25-5-5-1=44\)cases of apples being surrounded by apples.
This is the exact opposite of the case we want to find, so we do total cases - cases of apples being surrounded by apples for a total of \(70-44=26\) cases. Our final answer is 26 arrangements.