# A sequence of coin tosses

1. Oct 31, 2015

### toothpaste666

1. The problem statement, all variables and given/known data
Suppose a coin is tossed 14 times and there are 3 heads and 11 tails. How many such sequences are there in which there are at least 6 tails in a row?

3. The attempt at a solution
I will treat the sequence of coin tosses as a "word" where each letter is a toss and is either an H or T to represent the result of that toss. In order to ensure at least 6 tails in a row I will treat "TTTTTT" as a separate "letter". so now there are 14 - 6 + 1 = 9 letters in the word and there are 3 H's , 5 T's and 1 "TTTTTT"
we need to find the number of arrangements of these letters
there are 9 letters , 3 of type 1 , 5 of type 2 and 1 of type 3 so the total number of arrangements is
9!/3!5!1! = 9!/3!5!

is this correct?

2. Oct 31, 2015

### krebs

Code (Text):

counter = 0
validtosses = 0
matchingtosses = 0
bstring = ""

while not counter == int('11111111111111',2):  #tails = 1, heads = 0
bstring = '{0:08b}'.format(counter)  #convert our counter to binary string
if bstring.count("1") == 11:  #if there are exactly 11 tails increment validtosses
validtosses += 1
if not bstring.find("111111") == -1:  #if there is a string of "111111" increment matchingtosses
matchingtosses +=1
counter += 1

print "valid tosses: %d \n matching tosses: %d" % (validtosses, matchingtosses)

valid tosses: 364
matching tosses: 224

Your work is a little hard to follow. Are you sure you aren't double counting?:
HHH†TTTTT
HHHT†TTTT

are the same, but look different under your methodology († = TTTTTT)

EDIT: fixed!

Last edited: Oct 31, 2015
3. Oct 31, 2015

### andrewkirk

Why do you think that's the number of arrangements?

I doubt the answer will involve only factorials because the Tails are not distinguishable from one another, and neither are the heads.

We know that there is a string of at least six consecutive Tails. Call the first string of six Tails in that sequence Bob. How many tosses can there be before Bob begins? In the case where that number is k, how many different possible combinations are there of the other five tosses in the series?

Last edited: Oct 31, 2015
4. Oct 31, 2015

### krebs

EDIT: Made another error, now fixed:

So we will do a sequence like you suggested, with † = TTTTTT. There are 9 possible starting indices for †.
For a given index, n : 1 ≤ n ≤ 8, the formula for the number of combinations is as follows:
c = (8-n) choose (2) + (n-1)(8-n) + (n-1) choose 2 = 21

The reason for this is that, except for where n = 0, each successive value of n requires that † have an [H] immediately preceding it, otherwise it we will double count between indexes. Thus, 8-n is the amount of space on the right side of †, and n-1 is the amount of space on the left side of †, minus 1 because of the [H] that has to be preceding it. Of the two remaining head flips, two can be on the left "(n-1) choose 2", two can be on the right "(8-n) choose 2", or 1 can be on each side (n-1)(8-n).
For each of these 8 indices, we get 21 combos, or 168 total. We have to go back and calculate the value at n = 0, because when n = 0 it can't have an [H] preceding the †, so the formula above doesn't work. Instead, there are 8 spaces to the right and three [H] to distribute, so 8c3, which is 56. Thus the answer becomes 168+56 = 224

Last edited: Oct 31, 2015
5. Oct 31, 2015

### PeroK

First, your answer is 504, which is greater than 14-C-3 = 364. So, it can't be correct.

You can adapt your idea by considering two cases. One where there is an initial sequence of at least 6 tails. The second is where there is a word HTTTTTT somewhere.

You need the uniqueness of the string with 6 tails, as pointed out above.