I am trying to find a way to calculate all possible combinations of a sequence that have a certain length of long run.
When answering questions regarding sequences of heads and tails, sometimes participants will consider a sample space of longest run.
For a sequence of five coin flips, this is easy enough to calculate using a brute-force method - writing out all 32 possible sequences and then categorising them based on their longest run.
So, for example, a sequence with the longest run of 5 has a probability of 2/32 as there is only one way to have a longest run of 5 with a sequence of length 5.
However, I now have a sequence of length 10. I want to find out exactly how many sequences out of the 1024 possible sequences that have a longest run of 2 or 3.
I am assuming that it doesn't matter if the longest run is of heads or tails.
Is there a formula or code that could be used to calculate this?