[Math] bit string question

discrete mathematics

The question originally asked for four consecutive $1$s; this is the question that two of the answers address. It was later changed to ask for five consecutive $1$s.


How many bit strings of length $10$ contain either five consecutive $0$'s or five consecutive $1$'s?

Can someone please help with figuring out an approach? I'm not sure I have the correct answer. I got $296$.

Best Answer

6 types for five $0$'s:

XXXX100000
XXX100000X
XX100000XX
X100000XXX
100000XXXX
00000XXXXX

$5 \cdot 2^4 + 2^5 = 112$

7 types for four $1$'s:

XXXXX01111  !!! 1 repeat with (1) and 2 with (2)
XXXX01111X  !!! 2 repeats with (2)
XXX01111XX
XX01111XXX
X01111XXXX
01111XXXXX  !!! (1)
1111XXXXXX  !!! (2)

$6 \cdot 2^5 + 2^6 - 5 = 251$

They intersect in 8 obvious cases, so the answer is $112 + 251 - 8 = 355$