2

The following problem is from my textbook:

How many distinct 9-letter strings are possible out of the 17-letter string AAABBCCDEFGHIJKLM?

From this question I've learned about the generating function type of approach and after building the relevant polynomial (W|A link)

$$9!\bigg(1+x+\frac{x^2}{2!}+\frac{x^3}{3!}\bigg)\bigg(1+x+\frac{x^2}{2!}\bigg)^2\bigg(1+x\bigg)^{10}$$

the answer seems to be $898264080$ (the coefficient of $x^9$).

Yet it still felt as a black box so I've decided to do it by hand to make sure I understand.

\begin{array}{l|l} \text{Type} & \text{Number} \\ \hline \text{XXXYYZZ}\square\square & \binom{1}{1}\binom{2}{2}\binom{10}{2}\frac{9!}{3!2!2!} \\ \text{XXXYY}\square\square\square\square & \binom{1}{1}\binom{2}{1}\binom{11}{4}\frac{9!}{3!2!} \\ \text{XXX}\square\square\square\square\square\square & \binom{1}{1}\binom{12}{6}\frac{9!}{3!} \\ \text{XXYYZZ}\square\square\square & \binom{3}{3}\binom{10}{3}\frac{9!}{2!2!2!} \\ \text{XXYY}\square\square\square\square\square & \binom{3}{2}\binom{11}{5}\frac{9!}{2!2!} \\ \text{XX}\square\square\square\square\square\square\square & \binom{3}{1}\binom{12}{7}\frac{9!}{2!} \\ \square\square\square\square\square\square\square\square\square & \binom{13}{9}\frac{9!}{1!} \\ \end{array}

So for example the first line means that we have a sting where

  • one symbol appears three times (XXX), there is only one candidate
  • two symbols appear twice (YY and ZZ), there are only two candidates
  • and two more slots are occupied by the symbols which appear once, there are $10$ candidates and we choose $2$

Yet calculating the sum gives another number: $1329365520$ (W|A link).

I've checked it as best as I could, so the mistake seems to be conceptual. I'd greatly appreciate if someone alleviates my misunderstanding by pointing out the error.

Leo
  • 7,800
  • 5
  • 33
  • 68

1 Answers1

1

There's a bug in your code: it should be

9!*(c(10,2)/(3!2!2!)+2*c(11,4)/(3!2!)+c(12,6)/3!+c(10,3)/8+3*c(11,5)/4+3*c(12,7)/2+c(13,9))