[Math] How many bit strings

combinatoricsdiscrete mathematics

How many bit strings of length $8$ have either exactly two $1$-bit among the first $4$ bits or exactly two $1$-bit among the last $4$ bits?

My solution:

A bit only contains $0$ and $1$, so $2$ different numbers, i.e., $0$ and $1$. For the first part we have $2^6=64$ ways. Similar for the other way. Hence there exists $2^4=16$ bit strings. Is my answer true?

Update: I mean $2^6+2^6-2^4=112$ bit strings

Best Answer

I lost your logic. By symmetry, amount of strings with exactly 2 ones in the first four (call this group $F$) is identical to the ones with exactly 2 ones in the last four (call this group $L$).

Then your desired amount is $|F| + |L| - |F \cap L|$.

To compute $F$, note that you have exactly $\binom{4}{2} = 6$ ways to pick the location of the ones in the first four, which fixes your picks to be ones and the other two of the first four to be zeros. In other words, this fixes the first four bits, and the rest can be manipulated in $2^4=16$ ways.

Can you finish computing $|F|$? We already said $|L|=|F|$ and can you compute $|F \cap L|$ by a similar technique?