Counting Problem Involving a Work of Size N Imagine a programmer is creating a unique password consisting of n letters. Among the letters, two must contain a's and three must contain r's. The rest of the password can be formed using the remaining English letters. How many ways are there to arrange the letters in this password to create a unique string without having two 'a' in a row?
So far I have gotten:
$$\text{Having 5 positions already subtracted from our n, the remaining positions are: $n-5$} \\ \text{We have taken two letters from our alphabet so we have 24 more letters to choose from.} \\ \text{Choosing spots for a's and r's is: $\binom{n}{5}$ because we have the $5$ positions that are taken.} \\ \text{Ways to arrange these two letters(a and r) are $\binom{5}{3}$ because we have a total of $5$ letters and they take the $3$ positions?} \\ \text{We are left with 24 available letters and there is $24^{n-5}$ ways to put other letters in.} \\ \text{So far I have: $\binom{n}{5}\cdot\binom{5}{3}\cdot24^{n-5}$}$$
My question is where do I get the a's not in a row? Also, I don't know if $\binom{5}{3}$ is right, the one I left with a question mark.

Is right. To go on, first notice that $\binom{5}{3}=\binom{5}{2}$ cause it is the same selecting where are the a's to select where are the r's. Notice, further, that $\binom{n}{5}\binom{5}{2}=\binom{n}{2}\binom{n-2}{5-2}=\binom{n}{2}\binom{n-2}{3}$ which means, select first the a's, then the r's. To avoid the two a's in a row, first pick the positions of the a's, without placing anything else, and notice that if they are together, you can kind of merge them. So, from $\binom{n}{2}$ take out the merged pair. There are $n-1$ possibilities, so $\binom{n}{2}- (n-1).$ Your formula becomes
$$\left (\binom{n}{2}-(n-1)\right )\cdot \binom{n-2}{3}\cdot 24^{n-5}.$$
