3

The word DOLL has length $4$. There will be $18$ possible positions where 'DOLL' can appear, each with $3^{17}$ choices. So there will $18 \cdot 3^{17}$ cases where it can appear at least once. But I also know that there will be many duplicates in this approach. How do I go about removing them.

I can count those

  1. With DOLL appearing at least / only $5$ times as $\binom{6}{5}$ each with $3^{21-4 \cdot 5} = 3$ choices.
  2. With DOLL appearing at least $4$ times as
    • $21$ positions to place DOLL first time
    • $17$ positions to place DOLL second time
    • $13$ positions to place DOLL third time
    • $9$ positions to place DOLL fourth time
    • all with $3^{5}$ choices, so this gives $21 \cdot 17 \cdot 13 \cdot 9 \cdot 3^5$ possibilities
    • if I subtract all the choices that have $5$ occurrences of DOLL ($\binom{6}{5} \cdot 3$)from this, I will get only those that have $4$ occurrences of DOLL

But from here on how do I proceed for calculating $3$, $2$ and only $1$ occurrences. Do I apply the inclusion exclusion principle at each step or only when calculating for at most $1$ occurrence of DOLL.

N. F. Taussig
  • 76,571
lambda
  • 33

3 Answers3

3

"DOLL" can't self-overlap, so you can consider each occurrence of it as a separate block. There are $3^{21-4k}$ strings with "DOLL" in $k$ particular places, and $\binom{21-3k}k$ ways to choose the $k$ places, so by inclusion-exclusion there are

$$ \sum_{k=1}^5(-1)^{k-1}\binom k1\binom{21-3k}k3^{21-4k}=2002583502 $$

strings that contain "DOLL" exactly once.

joriki
  • 238,052
  • Could you explain the factor of $\binom{k}{1}$ in your summation? – N. F. Taussig Jun 01 '16 at 10:18
  • @N.F.Taussig: If there are $a_k$ ways to fulfill $k$ particular conditions out of $n$ conditions, then there are

    $$ \sum_{k=j}^n(-1)^{k-j}\binom kja_k $$

    ways to fulfill exactly $j$ conditions. A case in which exactly $m$ of the conditions are fulfilled is counted in $\binom mk$ of the $a_k$, and thus contributes

    $$ \sum_{k=j}^n(-1)^{k-j}\binom kj\binom mk=\delta_{jm};. $$

    – joriki Jun 01 '16 at 10:33
  • I do not fully understand your response. Humor me by addressing a simpler question. Say that there are $8$ letters rather than $21$. Your summation would become $$\sum_{k = 1}^{2} (-1)^{k - 1}\binom{k}{1}\binom{8 - 3k}{k}3^{8 - 4k} = 5 \cdot 3^4 - 2$$ Why $2$? Isn't there just one arrangement in which DOLL appears twice in a string of eight letters? – N. F. Taussig Jun 01 '16 at 10:50
  • 1
    @N.F.Taussig: That's right, there's one such arrangement. We've counted it twice and we want to count it $0$ times, so we need to subtract it twice. I just asked this question because this is not the first time I'm being asked about this by someone as knowledgeable as you :-) – joriki Jun 01 '16 at 10:53
  • @N.F.Taussig I follow that we would have counted DOLL twice, first by positioning it at first position, and then again by positioning DOLL at 5th position (in a string of length 8). So in my calculations, I was actually using $_2 P_2$ to detect this. – lambda Jun 01 '16 at 10:56
  • @N.F.Taussig: My explanation above wasn't well-phrased; I can't edit it now but I've improved it in the question I linked to. – joriki Jun 01 '16 at 11:06
  • @N.F.Taussig I really am thankful to you for your detailed reasoning. However, I wasn't able to ponder over your explanation in detail and if you don't mind I would like to have it's text for my own understanding. Is it possible that you can once again share the text, if it's still available ? Thanks once again – lambda Jun 01 '16 at 11:17
2

This answer is incorrect since I failed to account for the fact that we wish to count those arrangements in which DOLL appears exactly once. The issue is that when we apply the Inclusion-Exclusion Principle, we usually start with all the arrangements, then exclude the bad arrangements. In this case, we start with arrangements that include DOLL once, then wish to exclude arrangements that include DOLL more than once. See Joriki's answer for a correct solution and this question he posed about a generalized version of the Inclusion-Principle.

If DOLL appears once, we have $18$ objects to permute, the block containing DOLL and the other $17$ letters. As you concluded, we have $18$ choices for the position of the block and three choices for each of the other $17$ letters, so there are $$\binom{18}{1}3^{17}$$ arrangements in which DOLL appears once, as you found.

From these, we must exclude those arrangements in which DOLL appears more than once.

If DOLL appears twice, we have $15$ objects to permute, two identical blocks containing DOLL and the other $13$ letters. There are $\binom{15}{2}$ ways we can place the two blocks and three choices for each of the other $13$ letters, so there are $$\binom{15}{2}3^{13}$$ arrangements in which DOLL appears twice.

If DOLL appears three times, we have $12$ objects to permute, three blocks containing DOLL and the other $9$ letters. There are $\binom{12}{3}$ ways we can place the three blocks and three choices for each of the other $9$ letters, so there are $$\binom{15}{3}3^9$$ arrangements in which DOLL appears three times.

If DOLL appears four times, we have $9$ objects to permute, four blocks containing DOLL and the other $5$ letters. There are $\binom{9}{4}$ ways we can place the four blocks and three choices for each of the other $5$ letters, so there are $$\binom{15}{4}3^5$$ arrangements in which DOLL appears four times.

If DOLL appears five times, we have $6$ objects to permute, five blocks containing DOLL and the other letter. There are $\binom{6}{5}$ ways we can place the five blocks and three choices for the other letter, so there are $$\binom{6}{5}3$$ arrangements in which DOLL appears five times.

As you observed, DOLL cannot appear six times. Thus, by the Inclusion-Exclusion Principle, the number of arrangements of the letters $\{D,L,O\}$ with repetition in which DOLL appears only once is $$\binom{18}{1}3^{17} - \binom{15}{2}3^{13} + \binom{12}{3}3^9 - \binom{9}{4}3^5 + \binom{6}{5}3$$

N. F. Taussig
  • 76,571
  • You calculated the number of strings that contain "DOLL" at least once (and $\binom{18}{1}3^{17}$ doesn't count those strings). – joriki Jun 01 '16 at 10:12
  • 1
    @lambda I have posted the answer again with a warning about the Inclusion-Exclusion argument. My answer differs from Joriki's since it is missing the factor of $\binom{k}{1}$ needed to correctly count $k$ appearances of DOLL. – N. F. Taussig Jun 01 '16 at 11:27
  • @N.F.Taussig Thanks a lot ! – lambda Jun 01 '16 at 11:37
  • I have posted an answer which isn't really new, but just a supplement to yours. – user84413 Jun 06 '16 at 16:09
2

(This is simply a supplement to the two previous answers.)

As shown in N.F. Taussig's answer, the number of words with DOLL appearing at least once is given by

$\hspace{.5 in}\displaystyle\binom{18}{1}3^{17} - \binom{15}{2}3^{13} + \binom{12}{3}3^9 - \binom{9}{4}3^5 + \binom{6}{5}3=2,161,418,679$

Similarly, the number of words in which DOLL appears at least twice is given by

$\hspace{.5 in}\displaystyle\binom{15}{2}3^{13} -\binom{2}{1} \binom{12}{3}3^9 +\binom{3}{1} \binom{9}{4}3^5 -\binom{4}{1} \binom{6}{5}3=158,835,177$

Subtracting, we get $2,002,583, 502$ words in which DOLL appears exactly once,

as shown in joriki's answer.

user84413
  • 27,211