Consider the following pattern of characters:
$$ABFDEFA$$
I am tasked to find the number of arrangements where repeating characters in the pattern's permutation cannot sit next to each other.
My Solution:
I've only tried arranging a line where there are spaces between the repeating characters like so:
$$\_A\_A\_F\_F\_$$
Edit: forgot to say the repeating characters are distinguishable.
Then from that, find all the possible permutations of the repeating characters multiplied by $^5P_3$ since we can only choose 3 spaces from 5 available ones:
$$\frac{4!5!}{(5-3)!}$$
But this only gets me 1440 which is really too far away from the given answer which is 2640. What's the best solution for my problem here?
Since it is stipulated that the repeated letters are distinguishable, we wish to find the number of permutations of $A\mathcal{A}BDEF\mathcal{F}$ in which $A$ is not adjacent to $\mathcal{A}$ and $F$ is not adjacent to $\mathcal{F}$.
If there were no restrictions, the seven letters could be arranged in $7!$ ways. From these, we exclude those arrangements in which one or more of the restrictions is violated.
If $A$ and $\mathcal{A}$ are adjacent, we place them in an amber colored box. We then have six objects to arrange, the box and the other five letters. They can be arranged in $6!$ ways. The letters $A$ and $\mathcal{A}$ can be arranged in $2!$ ways within the box. Hence, there are $6!2!$ arrangements in which $A$ is adjacent to $A$.
By similar argument, there are $6!2!$ arrangements in which $F$ is adjacent to $\mathcal{F}$.
However, if we subtract $2 \cdot 6!2!$ from $7!$, we will have subtracted those in which $A$ is adjacent to $\mathcal{A}$ and $F$ is adjacent to $\mathcal{F}$ twice, once when we subtracted those arrangements in which $A$ is adjacent to $\mathcal{A}$ and once when we subtracted those arrangements in which $F$ is adjacent to $\mathcal{F}$. Therefore, we need to add the number of arrangements in which $A$ is adjacent to $\mathcal{A}$ and $F$ is adjacent to $\mathcal{F}$.
If we place $A$ and $\mathcal{A}$ in an amber colored box and place $F$ and $\mathcal{F}$ in a fuchsia colored box, we have five objects to arrange. They can be arranged in $5!$ ways. The object in each box can be arranged in $2!$ ways. Hence, the number of arrangements in which $A$ is adjacent to $\mathcal{A}$ and $F$ is adjacent to $\mathcal{F}$ is $5!2!2!$.
By the Inclusion-Exclusion Principle, the number of valid arrangements is $$7! - 2 \cdot 6!2! + 5!2!2! = 2640$$