5

I tried to use the principle of inclusion-exclusion.

The number of ways of getting 5 consecutive heads= $5×2^4$

The number of ways of getting 6 consecutive heads= $4×2^3$

Similarly, the number of ways of getting 7, 8, and 9 consecutive heads are $3×2^2, 2×2,$ and $1$, respectively.

So, the number of ways of getting at least 5 consecutive heads= $5×2^4-4×2^3+3×2^2-2×2+1$ = $57$

But the correct number would be 48. Where did I go wrong?

4 Answers4

7

A simple way to conceive it is that there are $5$ possible starting points for a streak of at least $5$ heads in $9$ tosses, and that except for the streak starting from the beginning, all other streaks must have a tail immediately preceding the streak.

Thus ans $= 1*2^4 + 4*2^3 = 48$

PS:

If you want to put it into a formula, let

  • $n$ = length of string,
  • $k$ = minimum length of streak desired
  • $j$ = maximum "non-streak" length possible $=n-k$

Then ans $= 1*2^j + (k-1)*2^{j-1}$

6

The error is in the way you have applied inclusion-exclusion. You found that the number of ways of getting $5$ heads consecutively (with overcounting) is $5 \cdot 2^4$, and $6$ heads consecutively (with overcounting) is $4 \cdot 2^3$. When you take $5 \cdot 2^4 - 4 \cdot 2^3$, you have already resolved all overcounting. For instance, the places where you get a largest string of $7$ heads consecutively, you count it $3$ times in the first case in $2$ times in the second. Indeed, we do have $5 \cdot 2^4 - 4 \cdot 2^3 = 80 - 32 = 48$.

Haran
  • 11,978
  • 1
  • 19
  • 56
3

Others have pointed out the problem with your application of Inclusion-Exclusion, so it might be worth pointing out that there is an easier approach which works better for larger $n$.

Let $a_n$ denote the number of binary strings in $H,T$ with no block of the form $H^5$ (so you want to count $2^n-a_n$. For small $n$ we easily see that $$(a_1,a_2, a_3,a_4,a_5)=(2,4,8,16,31)$$

For $n>5$ we see that any good string must begin with one of: $T,HT, HHT, HHHT,HHHHT$ and then be followed by a good word of shorter length. It follows that $$a_n=a_{n-1}+a_{n-2}+a_{n-3}+a_{n-4}+a_{n-5}$$

Thus the sequence, starting at $a_6$ continiues as $$\{61,120,236,464,\cdots\}$$

From which we can read off that the answer to your question was $512-464=48$.

lulu
  • 76,951
2

We can construct the sets of solutions, according to where the first sequence of 5 consecutive heads starts (thus making the sets disjoint):

  1. HHHHHXXXX ($2^4=16$ cases since there are 4 X)
  2. THHHHHXXX ($2^3=8$ cases)
  3. XTHHHHHXX ($2^3=8$ cases)
  4. XXTHHHHHX ($2^3=8$ cases)
  5. XXXTHHHHH ($2^3=8$ cases)

Total is $48$.

The question's "The number of ways of getting 5 consecutive heads= $5×2^4$" comes with no rationale, and needs no further refutation.

fgrieu
  • 1,828