Counting ternary strings of length $6$ with exactly two $0$'s, at least one $0$

926 Views Asked by At

A. How many ternary strings of length $6$ contain exactly two $0$s.
B. How many ternary strings of length $6$ contain at least one 0.

For A I think it's $\frac{6!}{(6-2)!}*2^4$ because the first part would be choosing $2$ $0$s and the second part filling the rest of the $4$ slots with either only $1$s or $2$s and then for part B I got $\binom{6}{1}\frac{6!}{(6-1)!1!}$ because choosing $1$ zero would give you at least one zero?

2

There are 2 best solutions below

0
On

For A you choose the positions for the zeroes in $\binom{6}{2}$ ways and then for each of the remaining 4 spots we have 2 choices (either one or two). Hence the number of ways is $\binom{6}{2}\times 2^4$.

For B it is easiest to consider the set of length 6 ternary strings without a zero (this is the complement). There are $2^6$ such strings (each position is either a one or a two). There are $3^6$ ternary strings strings of length 6 (we have three choices for each position). Hence there are $3^6-2^6$ ternary strings of length $6$ with at least one zero.

4
On

Let's begin with the second part: How many ternary strings of length $6$ contain at least one $0$.

The only alternative to "at least one $0$" is that the string contains no $0$. The number of strings (of length six) with no $0$, if the strings are ternary, is $2^6$. So I think that you should be subtracting $2^6$ from $3^6$. Using combinations as you did doesn't make sense to me since you are counting numbers of subsets of a given size, but ternary strings aren't easily represented as subsets. On the other hand, it is easy and natural to map back and forth between a binary string and a subset.