[Math] How many permutations of letters ABCDEFG contain the strings ABC and CDE

discrete mathematicspermutations

For this problem, I understand how to find something like how many strings contain the string BA and GF. I just look at the set of letters like this:

{BA, GF, C, D, E}

and since I have 5 distinct elements I can calculate the number of permutations with 5!.

However, I am not sure what to do when the two strings overlap such as the number of permutations which contain the string ABC and CDE or CBA BED.

Best Answer

Add the two situations individually and subtract the overlap.