How many ways can you arrange all letters in the word "management" so that at least one "m" is adjacent to one "a"?

In the following, we try to solve the compliment problem by constructing all permutations of $\mathtt {management}$ with no adjacent pair of $\mathtt a$ and $\mathtt m$.

  1. Form each of the $6 = \frac {4!} {2!2!}$ permutations of the word $\mathtt {aamm}$. They all have an adjacent pair of $\mathtt a$ and $\mathtt m$, and
    • two of them have one such adjacent pair, namely $\mathtt {aamm}$ and $\mathtt{mmaa}$,
    • two of them have two such adjacent pairs, namely $\mathtt {amma}$ and $\mathtt{maam}$, and
    • two of them have three such adjacent pairs, namely $\mathtt {amam}$ and $\mathtt {mama}$.
  2. Insert in each of these words gap symbols where you want to separate such adjacent pairs, e.g. $\mathtt {aa–mm}$ and $\mathtt {a–mm–a}$. Then interpret every letter-gap combination as one character, e.g. $\mathtt {aa–mm}$ has the character “$\mathtt {a–}$” in it. Of the resulting $4$-character words, there are now
    • two gap-words with one gap,
    • two gap-words with two gaps, and
    • two gap-words with three gaps.
  3. Distribute each of these gap-words on the $9$, $8$ or $7$ slots that remain from the ten characters of length in a permutation of $\mathtt{management}$ after accounting for letter-gap combinations (considering that a letter-gap combination is supposed to occupy two characters). There are

    • $126 = {9 \choose 4}$ ways to distribute $4$ characters on $9$ slots,
    • $70 = {8 \choose 4}$ ways to distribute $4$ characters on $8$ slots,
    • $35 = {7 \choose 4}$ ways to distribute $4$ characters on $7$ slots.
  4. Reinterpret in each of these distributions the letter-gap combinations again as two characters. Then remove in each the gap symbols and put in the remaining letters on the slots that are still vacant. There are $180 = \frac {6!} {2!2!}$ permutations of the word $\mathtt {eegnnt}$, so there are $180$ ways to put in the remaining letters in order.

Now you should have counted the number of ways to rearrange the letters of $\mathtt {management}$ such that there is no adjacent pair of the letters $\mathtt a$ and $\mathtt m$. I hope I didn’t count any doubles by mistake.

My answer would then be that there are $$83 160 = (2·126 + 2·70 + 2·35)·180$$ ways to do this. That would be the complement of your problem. Since there are $226800 = \frac {10!} {2!2!2!2!}$ permutations of $\mathtt {management}$, you end up with $$143 640 = 226 800 - 83 160$$ ways to rearrange the letters of $\mathtt {management}$ with at least one adjacent pair of the letters $\mathtt a$ and $\mathtt m$.

Combinatorics isn’t my thing, though, so better check my answer twice for any mistakes.

Update. See? I told you combinatorics wasn’t my thing. Torsten has found that I did count a lot of stuff twice – many thanks! I have now fixed my solution. Since I get the same numbers as Torsten now, I feel quite confident that the solution now is correct.


Here is another way to compute the complement, i.e. how many ways there are to arrange the letters with no MA or AM.

First, distribute the other letters EENNGTT; as noted in the other answer, there are $\dfrac{10!}{2!2!2!2!} = 180$ ways to do this.

Write them down and put slots where the remaining M's and A's could go, like:

_E_E_N_N_G_T_

So there are in principle $7$ slots for the remaining letters. Now we either

  • choose four of the slots, and then distribute the letters in them (automatically no MA or AM): $\binom{7}{4} \cdot \dfrac{4!}{2!2!} = 210$ options, or

  • choose three of the slots, then choose one of the three chosen one for a double letter, then choose whether we want a double M or double A (as MA and AM are forbidden): $\binom{7}{3} \cdot 3 \cdot 2 = 210$, or

  • choose two of the slots; if one contained three or four of our MAMA, we could not avoid an adjacent pair, so both have to have a two letters in them, i.e. one of them will have to have AA and the other MM in it; choose which one: $\binom{7}{2} \cdot 2 = 42$

  • if we chose just one slot for the AAMM, we could not avoid adjacent M and A, so that's it.

In total, we have $210+210+42=462$ options. Multiply with $180$ for the distribution of the other letters, gives

$$462 \cdot 180 = 83'160$$

ways to reorder the letters without MA or AM. Since the total number of arrangements is $\dfrac{10!}{2!2!2!2!} = 226'800$, the answer to your question is

$$226'800-83'160=143'640.$$