I have 4 different color balls B1, B2, B3 and B4 and their quantity is given by n1, n2 ,n3 and n4 respectively.
Now, I want to arrange these balls in a straight line next to each other. However, in this arrangement I want no two balls of the same color to be adjacent to each other.
ex: if there is 1 ball for each of 4 colors then answer would be 4! = 24
I'm not able to come up with a generic formula for this. Can somebody help me with this?
Update: So I went through that duplicate marked question and the answer mentioned there doesn't has any generic formula which solves my problem!