<s>[INST] Generating function with tough restrictions 
In how many ways can a coin be flipped $25$ times in a row so that exactly $5$ heads occur and no more than $7$ tails occur consecutively?

For the heads, I think that it is $\binom{25}{5}$, but I do not know what to do with the tails restriction. 
Not sure how to approach this problem. It is from the advanced section in the generating functions chapter in my book.
 [/INST] This answer is based upon the Goulden-Jackson Cluster Method.

We consider the set words of length $n\geq 0$ built from an alphabet $$\mathcal{V}=\{H,T\}$$ and the set $B=\{TTTTTTTT\}$ of bad words, which are not allowed to be part of the words we are looking for. We derive a generating function $f(s)$ with the coefficient of $s^n$ being  the number of searched words of length $n$.

According to the paper (p.7) the generating function $f(s)$  is
\begin{align*}
f(s)=\frac{1}{1-ds-\text{weight}(\mathcal{C})}\tag{1}
\end{align*}
with $d=|\mathcal{V}|=2$, the size of the alphabet and $\mathcal{C}$ the weight-numerator of bad words with
\begin{align*}
\text{weight}(\mathcal{C})=\text{weight}(\mathcal{C}[TTTTTTTT])
\end{align*}

We calculate according to the paper
  \begin{align*}
\text{weight}(\mathcal{C}[T^8])&=-s^8-s\cdot \text{weight}(\mathcal{C}[T^8])-\cdots-s^7\cdot\text{weight}(\mathcal{C}[T^8])\tag{1}\\
\end{align*}
and get
  \begin{align*}
\text{weight}(\mathcal{C})=\text{weight}(\mathcal{C}[T^8])=-\frac{s^8(1-s)}{1-s^8}
\end{align*}
It    follows
\begin{align*}
f(s)&=\frac{1}{1-ds-\text{weight}(\mathcal{C})}\\
&=\frac{1}{1-2s+\frac{s^8(1-s)}{1-s^8}}\tag{2}\\
&=\frac{1+s^8}{1-2s+s^9}\\
&=1 + 2 s + 4 s^2 + 8 s^3 + 16 s^4 +\cdots+\color{blue}{32\,316\,160}s^{25}+\cdots\\
\end{align*}
The last line was calculated with the help of Wolfram Alpha.  The coefficient   of $s^{25}$  shows that out of $2^{25}=33\,554\,432$ words of length $25$ from the alphabet $\{H,T\}$ there are $\color{blue}{32\,316\,160}$  words which do not contain the word $TTTTTTTT$.

But we also want to keep track of the number of heads and tails. In order to do so we make a refinement of $f(s)$ by marking the heads with $x$ and the tails with $y$. We obtain from (1)
\begin{align*}
\text{weight}(\mathcal{C}[T^8])&=-(ys)^8-(ys)\text{weight}(\mathcal{C}[T^8])-\cdots-(ys)^7\text{weight}(\mathcal{C}[T^8])
\end{align*}
and get
\begin{align*}
\text{weight}(\mathcal{C})=-\frac{(ys)^8(1-ys)}{1-(ys)^8}\tag{2}
\end{align*}

Using this generalized weight we obtain from (2) a generating  function $g(s;x,y)$
\begin{align*}
g(s;x,y)&=\frac{1}{1-(x+y)s+\frac{(ys)^8(1-ys)}{1-(ys)^8}}\\
&=1+(x+y)s+(x+y)s^2+(x+y)^3s+\cdots\\
&\qquad+(x^{25} + 25 x^{24} y + 300 x^{23} y^2 + 2\,300 x^{22 }y^3 +\cdots+\color{blue}{ 17\ 892} x^5 y^{20} \\
&\qquad\qquad+ 2\,010 x^4 y^{21} + 84 x^3 y^{22})s^{25}+\cdots\tag{3}
\end{align*}
We finally conclude from (3) there are $\color{blue}{ 17\ 892}$ words of length $25$ which contain exactly $5$ heads and do not contain more than $7$ consecutive tails.

</s>