Given R red balls, B blue balls and G green balls, how many ways are there to arrange them on a straight line such that no two balls of the same color are next to each other?
In essence, my question is a generalization of this question.
In the above post, the accepted answer enumerates all cases in which there is a violation of the restriction. As such, it may not be so easy to compute if the quantity of each ball is large (e.g. 100 of each ball) as we have to compute each case manually.
I wish to ask if there is a generalized formula/expression that can answer the same question for R red balls, B blue balls and G green balls (It doesn't matter even if the expression is not in closed-form because I want to compute this on a computer).
Could someone please advise me?
You can have a look here for a number of approaches.
Choose the one that suits you best.