<s>[INST] Generating function for the number of strings following a certain pattern. Let $f_n$ denote the number of strings of length $n$ using letters $A,B,C$ and $D$ such that there are even number of $A's$; $1,2,3$  or $4 \ B's$; either $2$ or $5$ $C's$ and at least $1$ $D$.
So $f_0 = f_1 = f_2 = f3 = 0$, $f_4 = 12$ and $f_5 = 60$. To find the generating function for $f_n$.

I was trying to find a recurrence relation for $f_n$.
Its fine that there is at least one $D$.
But how to control how many $B's$ and $C's$ we have already used?
 [/INST] $\color{blue}{\text{Generating Function:}}$
I think that exponential generating functions is the best choice for your question.

*

*If there are even number of $A's$ , then E.G.F of $A$ is : $$1+\frac{x^2}{2!}+\frac{x^4}{4!}+\frac{x^6}{6!}+...+\frac{x^{2k}}{(2k)!}+..=\frac{e^x + e^{-x}}{2}$$


*E.G.F of $B's$ : $$\bigg(\frac{x^1}{1!}+\frac{x^2}{2!}+\frac{x^3}{3!}+\frac{x^4}{4!}\bigg)$$


*E.G.F of $C's$ : $$\bigg(\frac{x^2}{2!}+\frac{x^5}{5!}\bigg)$$


*E.G.F of $D's$ : $$\bigg(\frac{x^1}{1!}+\frac{x^2}{2!}+\frac{x^3}{3!}+\frac{x^4}{4!}+...\bigg)=(e^x -1)$$
For any desired $n$ find the coefficient of $x^n$ and multiply it by $n!$ in the expansion of $$n![x^n]\bigg[\bigg(\frac{e^x + e^{-x}}{2}\bigg)\bigg(\frac{x^1}{1!}+\frac{x^2}{2!}+\frac{x^3}{3!}+\frac{x^4}{4!}\bigg)\bigg(\frac{x^2}{2!}+\frac{x^5}{5!}\bigg)(e^x -1)\bigg]$$
$\color{red}{\text{EXPANSION:}}$

For example , for $n=5$  , $$5! \times \frac{1}{2}=60$$
</s>