Permutation Of String of length n with A B C

245 Views Asked by At

So I have to count the number of words of length N can be made with alphabets A B and C. (repetition allowed)

But condition is A's should not be together B'S should not be together. and at-most m C's are allowed.

e.g For words of length n=2 and m=1 (c is allowed only 1 time) the following are allowed:

AB AC BA BC CA CB Not allowed are AA BB CC (CC is not allowed because atmost 1 C is allowed).

Can anyone please help

1

There are 1 best solutions below

2
On

The $C$s break the string into runs of $AB$s. Each run has two choices because it can start with $A$ or $B$, then all the other letters are fixed. I don't see an easy way to catalog them, but if $n=7,m=2$ you can have one run of $AB$, which happens if there are no $C$'s (one possibility), one $C$ at the end (two possibilities), or two $C$'s at the ends (three possibilities) for a total of $12$. You can have two runs of $AB$ if there is one $C$ in the middle (five possibilities), one $C$ at the end and one in the middle (eight possibilities), or two $C$'s together in the middle (four possibilities) for a total of $48$. You can have three runs of $AB$ if the two $C$'s are in the middle and separated (six possibilities) for $48$ total. The grand total is then $108$