In: Computer Science
Suppose there are unlimited number of Red, Green, and Blue balls, You want to select
n balls and the orders matter. The selected balls must meet the following rule: Two adjacent balls must not be both Red or both Blue. How many options do you have when n is 4?
For simple understanding let's divide question into two conditions.condition 1: selecting n balls out of unlimited number of Red,Green,Blue balls
Condition 2:order should be no two reds or two blue balls are adjacent.
Formula (n+r−1)C(r-1);This means you have to distribute n things among r people where anyone can get any number of things.
This formula is also used to solve algebraic permutation
X+Y+Z=n ; n≥0
Then number of solution of this equation is also given by the same formula.
So here we have 3 types of ball Red(R) ,Blue(B) and Green(G).
From this we have to select 4 balls. i.e total which we are going to pick should be equal to 4.
R+B+G=4
Number of ways of doing this is (4+3−1)C(3−1)=6C2
=15
4,5,6,7,8,9,12,13,14 are 9 types of selecting balls .Now we need to check each type with arranging ways
Example
Choosing 2R and 2B
RBRB ,BRBR -2 ways
Like this if we check four balls with 2G2B ,2G2R ....,4G we get 25 ways of arranging four balls of 3different colors such that no two red or two blue balls were adjacent
Therefore arranging four balls such that no two red and two blue balls adjacent is 25 ways