How many binary strings of length 11 contain five consecutive 0s or five consecutive 1s？ The answer is 502 but why?
I use $$(^7C_1\cdot2^6-^6C_1\cdot2^5)\cdot2-2$$
$C(7,1)*2^6$ count 11111 and 00000 as one number
$-C(6,1)*2^5$ more than 6 consecutive 111111 or 000000 count twice(1111111 three times etc.)
11111011111 and 00000100000 count twice
 A: Let's start with this: a sequence of bits has a $5$-bit streak starting at the $k$th bit if bits $k$ through $k+4$ are all the same and bit $k-1$ either doesn't exist or is different.
So, for an 11-bit number: $2*2^6$ of them will have a streak starting at the $0$th bit, because there are six free bits after the streak; and $6*2*2^5$ of them will have a streak starting at the 1st through 6th bits because committed both before and after there are $5$ free bits.  This gives $512$ ways to do it, but there are a few duplicates, which we'll need to find.
It is possible for two streaks to exist if they start 6 or more bits apart and use the same value, or 5 or more bits apart and use different values.  This gives 0th and 5th with different streaks, 0th and 6th with same or different streaks, and 1st and 6th with different streaks.
00000111110
00000111111
11111000000
11111000001
00000100000
00000011111
11111011111
11111100000
10000011111
01111100000

There are ten of these and each has been counted twice, so we must subtract $10$ from our initial count, for a total of $502$.
