1
$\begingroup$

Question: How many words is it able to create from the letters $LYCANTHROPIES$ so $C$ won't stand next to $A$ won't stand next to $N$ and $N$ won't stand next to T.

I thought about $13! - 3\cdot 2 \cdot 12! - 2 \cdot 10!$, when $13!$ is the maximum number of words I can create with no limitations, $2 \cdot 12!$ is the number of words when two letters stand next to each other (there are 3 options for this situation) and finally the situation when all the "forbidden" letters stand next to each other ($2 \cdot 10!$).

But the answer is $13! - 3 \cdot 2 \cdot 12! + 2 \cdot 2 \cdot 11! + 2 \cdot 2 \cdot 11! - 2 \cdot 10!$

Any idea what am I missing?

  • 0
    Hint: think about strings like ...CAN... and ... ANT...2017-02-04
  • 0
    Do you mean so C won't stand next to A, A won't stand next to N, and N won't stand next to T?2017-02-04
  • 0
    Probably yes, I wrote it as it was written in my book.2017-02-04

2 Answers 2

0

At first we see that $LYCANTHROPIES$ consists of $13$ pairwise different characters.

The number of all words of length $13$ which can be built from these characters is \begin{align*} 13! \end{align*}

Forbidden subwords are the following six words \begin{align*} &AC,CA,\\ &AN,NA\\ &NT,TN \end{align*}

Therefore we have to subtract all words which contain (at least) one of these six forbidden words from $13!$ \begin{align*} -3\cdot 2\cdot 12!\tag{1} \end{align*}

Since some words contain more than one forbidden word, these are counted more than once in (1) and we have to compensate for it.

We consider two different cases. Words which contain two forbidden subwords consisting of four different characters and words which contain two forbidden subwords consisting of three different characters which do overlap. They are \begin{align*} &AC,NT&ANT\\ &AC,TN&CAN\\ &CA,NT&NAC\\ &CA,TN&TNA \end{align*}

So, we have to add the number of these words giving \begin{align*} +2\cdot 2\cdot 11!+2\cdot 2\cdot 11!\tag{2} \end{align*}

In (2) we count the words which contain three forbidden words too often and we have to compensate for them. Since each character occurs exactly once, the following two forbidden triplets are to consider \begin{align*} CANT, TNAC \end{align*}

So, we have to subtract \begin{align*} -2*10! \end{align*}

and we finally obtain \begin{align*} 13!-3\cdot 2\cdot 12!+2\cdot 2\cdot 11!+2\cdot 2\cdot 11!-2\cdot 10! \end{align*}

Note: This answer follows the inclusion-exclusion principle.

  • 0
    I understand all but one thing - in the second case (2), shoudn't we consider also the options when $NT$ or $TN$ are the first to appear? for example, the string $NTAC$ does not appear in your calculation.2017-02-04
  • 0
    @Eusebius: Good question. We consider *all* $11!$ words which contain $\{AC,NT\}$. This subsumes words containing $*AC*NT*$ as well as $*NT*AC*$.2017-02-04
  • 0
    I see it now. For check, the strings containing two forbidden subwords consisting of three different characters such as $ANT$, another optional order contains ${AN,T} is $TAN$ so I don't need to count it separately?2017-02-04
  • 0
    @Eusebius: No, this is not correct. The reason is that $TA$ is not a forbidden subword. So $TAN$ is not an overlap of two forbidden words.2017-02-04
0

Under the restrictions, there are the following forbidden strings:

$3\cdot 2 = 6$ strings of $2$ letters: $CA$, $AC$, $AN$, $NA$, $NT$, $TN$
$2\cdot 2 = 4$ strings of $3$ letters: $CAN$, $NAC$, $ANT$, $TNA$
$2$ strings of $4$ letters: $CANT$, $TNAC$

Using inclusion-exclusion, we can find the unrestricted option count, then subtract off all those where a pair of letters violates the constraint (by treating that pair as a single letter). at this point we have removed some cases twice, so we try to add back in all the three-letter sets and all the distinct pairs that have been doubly-removed, and finally subtract off again for the four letter sets that have now been wrongly restored.

This gives the answer as expected of $13!-6\cdot 12!+4\cdot 11!+4\cdot 11!-2\cdot 10!$