Solve the following question via exclusion and inclusion principles. This question was a bit more tricky then other questions I have faced so I am wondering if my workings are correct, thanks!
How many arrangements of the $26$ different letters are there that contain neither the sequence "the" nor the sequence "math"?
We know that there are $24!$ arrangements that contain the sequence "the", so there are $(26! - 24!)$ sequences that do not, as there are 26! arrangements without restrictions.
Next, considering "math" as one element, we can arrange this and the remaining 22 letters in 23! ways. Thus there are $(26! - 23!)$ arrangements that do not contain the sequence "math".
Finally, we must consider those arrangements that contain the sequence "mathe", as we will have deducted these arrangements twice in the first $2$ steps. By similar reasoning to above, there are $22!$ arrangements that include "mathe", thus we will need to add $22!$ to the sum from the first $2$ steps.
This gives us a final answer of $\left[(26! - 24!) + (26! - 23!) + 22!\right] $ arrangements.
Let $S$ denote the set of all permutations of the alphabet; let $M$ denote the set of all permutations of the alphabet that contain the subsequence math; let $T$ denote the set of all permutations of the alphabet that contain the subsequence the.
We wish to count all permutations in the alphabet that contain neither the subsequence math nor the subsequence the. That is, we wish to count the number of elements in the set $M^C \cap T^C$.
Since $M^C \cap T^C = S - (M \cup T)$, $$|M^C \cap T^C| = |S| - |M \cup T|$$ By the Inclusion-Exclusion Principle, $$|M \cup T| = |M| + |T| - |M \cap T|$$ Hence, $$|M^C \cap T^C| = |S| - |M| - |T| + |M \cap T|$$ You correctly found that \begin{align*} |S| & = 26!\\ |M| & = 23!\\ |T| & = 24!\\ |M \cap T| & = 22! \end{align*} Hence, $$|M^C \cap T^C| = 26! - 23! - 24! + 22!$$
You added the number of sequences that do not contain the subsequence math, the number of subsequences that do not contain the word the, and the number of subsequences that contain both math and the, that is, $$|M^C| + |T^C| + |M \cap T|$$ Draw a Venn diagram as follows: Draw a rectangle that includes two overlapping circles. The rectangle represents the set $S$ of all permutations of the alphabet. Label one of the circles, say the one on the left, $M$. It represents the set of sequences that contain the subsequence math. Label the other circle $T$. It represents the set of sequences that contain the subsequence the. The region where the two circles intersect is $M \cap T$. The region inside the rectangles but outside the circles is $M^C \cap T^C$, which is what we want to count since is the set of sequences in $S$ that contain neither the subsequence math nor the subsequence the.
If we shade $M^C$ (with, say, lines from the lower left to the upper right), we shade everything in $S$ except for $M$. Thus, we have already shaded $M^C \cap T^C$ and the part of set $T$ outside $M$. If we now shade $T^C$ (with, say, lines from the upper left to the lower right), we shade everything in $M^C \cap T^C$ again and the region of $M$ outside $T$. We then shade $M \cap T$ (with, say, horizontal lines). Notice that we have now shaded $M \cup T$ once and $M^C \cap T^C$ twice. Put another away, we have shaded all of $S$ once and then shaded $M^C \cap T^C$ a second time. Consequently, what you counted is $$|M^C| + |T^C| + |M \cup T| = |S| + |M^C \cup T^C|$$ Using my answer above for $|M^C \cap T^C|$, we obtain $$|S| + |M^C \cap T^C| = 26! + 26! - 23! - 24! + 22!$$ which explains why you have an extra $26!$ term in your answer.