Problem (Combinatorics):
The string $A A A B B B A A B B$ is a string of ten letters, each of which is $A$ or $B$, that does not include the consecutive letters $A B B A$.

The string $A A A B B A A A B B$ is a string of ten letters, each of which is $A$ or $B$, that does include the consecutive letters $A B B A$.

Determine, with justification, the total number of strings of ten letters, each of which is $A$ or $B$, that do not include the consecutive letters $A B B A$.

Solution:
There are $2^{10}=1024$ strings of ten letters, each of which is $A$ or $B$, because there are 2 choices for each of the 10 positions in the string.

We determine the number of these strings that do not include the "substring" $A B B A$ (that is, that do not include consecutive letters $A B B A$ ) by counting the number of strings that do include the substring $A B B A$ and subtracting this total from 1024.

If a string includes the substring $A B B A$, there are 7 possible positions in which this substring could start ( $A B B A x x x x x x, x A B B A x x x x x, \ldots, \operatorname{xxxxxxABBA).}$

There are 2 choices for each of the remaining 6 letters in such a string, so there are $7 \cdot 2^{6}=448$ occurrences of the substring $A B B A$ among the 1024 strings.

This does not mean that there are 448 strings that contain the substring $A B B A$. Since $A B B A$ can appear multiple times in a single string, this total will count some strings more than once. (For example, the string $A B B A A A A B B A$ is included in both the first and seventh of these categories, so this string is counted twice.)

So we must "correct" this total of 448 by accounting for the strings in which $A B B A$ occurs more than once.

We note that, since two substrings of $A B B A$ can overlap in 0 letters (for example, $A B B A A B B A x x$ ) or in 1 letter (for example, $A B B A B B A x x x$ ), then the maximum number of times that the substring $A B B A$ can appear is 3 , and there is only one such string: $A B B A B B A B B A$.

If a string contains two copies of $A B B A$ that overlap, then it must be of one of the following forms:

$A B B A B B A x x \quad x A B B A B B A x x \quad x x A B B A B B A x \quad x x x A B B A B B A$

Since there are 4 choices for the starting position of $A B B A B B A$ and 2 choices for each of the three unknown letters, then there are $4 \cdot 2^{3}=32$ occurrences of $A B B A B B A$ among all of these strings.

But the string $A B B A B B A B B A$ is counted in each of the first and last categories, so we subtract 2 occurrences from this total to obtain 30 , the total number of strings of ten letters that included exactly two overlapping copies of $A B B A$. (We'll count the string $A B B A B B A B B A$ later.)

If a string contains exactly two substrings of $A B B A$ and these do not overlap, then it must be of one of the following forms:

$$
\begin{array}{lll}
A B B A A B B A x x & A B B A x A B B A x & A B B A x x A B B A \\
x A B B A A B B A x & x A B B A x A B B A & x x A B B A A B B A
\end{array}
$$

Since there are 6 such forms and 2 choices for each of the 2 unknown letters in each case, then there appear to be $6 \cdot 2^{2}=24$ such strings.

This total includes the string $A B B A B B A B B A$ in the third category, so we subtract 1 from this total to obtain 23 , the total number of strings of ten letters that include exactly two copies of $A B B A$ which do not overlap.

So there are 30 strings that contain exactly two overlapping substrings $A B B A, 23$ strings that contain exactly two non-overlapping substrings $A B B A$, and 1 string that contains exactly three substrings $A B B A$.

To get the total number of strings with one or more substrings $A B B A$ we take the total number of occurrences of $A B B A$ (448), subtract the number of strings with exactly two substrings $A B B A$ (since these were included twice in the original count), and subtract two times the number of strings with exactly three substrings $A B B A$ (since these were included three times in the original count).

Therefore, there are $448-23-30-2 \cdot 1=393$ strings that include at least one substring
$A B B A$, and so there are $1024-393=631$ strings of ten letters that do not include the substring $A B B A$.

Final answer: 631