Yeah I agree I missed RBBRRB or BBRRBR
I dont know how to solve this problem using formulas.
Anand, as a programmer, you could write some algorithm to solve it. My friend solved this problem for N red and N green (it was given at all-Kazakh programming contest
). Kazakhstan is a large country in Central Asia (former Soviet Union).
My answer is:
The method is as follows:
1. Think about combinations where all Bs are actually non-sequential. There is only 1 such comb.
2. Think about combs where only 2 Bs are sequential, but the remaining is not. => 2 combs.
3. Think about combs where all three B are sequential => there is only 1 such comb.
=> 4 is the answer.
The general method for (N greens, N reds) is as follows:
1. with no neighbors = 1.
2. with only 1 pair of 2 neighbors = N-1.
3. with only 2 pairs of 2 neighbors, ... etc.
So, it can be easily done even for N = 4,5.