How many strings are there (inclusion exclusion principle)

246 Views Asked by At

Q: What is the number of strings with the length of $8$ above $\left\{1,2,\cdots,10\right\}$ where $7,8$ appears at least one time?

So by using the inclusion exclusion principle:

  • $10^8$ is the total number of possibilities
  • $2\cdot 9^8$ - $7$ or $8$ doesn't appear
  • $8^8$ - both $7,8$ doesn't appear.

All in all we have:
$$ 10^8 - 2\cdot 9^8 + 8^8$$

"Alternative" answer:
Choose two places for $7,8$: $ 8\choose 2$.
Then, we have six more places to fill with no limitations.
Finally, we multiply by $2!$ (permutations number of $\left\{7,8\right\}$).

Therefore, $$2\cdot C(8, 2)\cdot 10^6$$

Question:
What is the difference between the two answers? (Their value isn't the same)

1

There are 1 best solutions below

0
On BEST ANSWER

Your alternative solution counts some combinations more than once.

Pick locations $1$ and $2$ for $8$ and $7$, then you will get a string like this in your counts:

$$87111187$$

But you can get this string even when you pick the $7$th and $8$th locations for $8$ and $7$ and "fill" the remaining.