TITLE: A combinatorial question about odd and even numbers
QUESTION [7 upvotes]: Consider an $n$ tuple. Each index of the tuple is filled with a symbol chosen from the following set comprising of four symbols:
\begin{equation}
S = \{a, b, c, d\}.
\end{equation}
Note that there are $4^{n}$ possible fillings.
I want to count the number of possible tuples such that $b$-s, $c$-s, and $d$-s all occur in it an even number of times (not necessarily the same even number for each.)
For example, if $n = 4$, then $bbba$ is not a valid tuple --- as it has $3$ $b$-s, which is an odd number. However $bb cc$ is a valid tuple — as both $b$ and $c$ occur an even number of times.

For $n = 2$, the valid choices are $aa, bb, cc, dd$.
Hence, the number of such tuples is $4$.
For $n = 3$, the valid choices are $aaa, abb, acc, add, bba, cca, dda, bab, cac, dad$.
So, $10$ choices.
Is there a general pattern?

REPLY [3 votes]: This problem is amenable to exponential generating functions. Indeed,
the egf for the $a$'s is given by
$$
A(x)= \sum_{n=0}^\infty\frac{x^n}{n!}=e^x
$$
while the egfs for the $b$'s, $c$'s and $d$'s are simulatenously equal to
$$
B(x)=\sum_{n=0}^\infty\frac{x^{2n}}{(2n)!}=\frac{e^x+e^{-x}}{2}.
$$
Hence the egf for the number of words of length $n$ with the required restrictions $c_n$ is given by
$$
C(x) = A(x)B(x)^3 = \sum_{n=0}^\infty\left(
\sum_{ \substack{x_{1}+x_{3}+x_{3} + x_{4} = n\\ \quad x_{1}\geq 0, \;x_{2},\; x_{3}, \; x_{4} \;\text{even}}} \frac{n!}{x_1!x_2!x_3!x_4!}\right)\frac{x^n}{n!}=\sum_{n=0}^\infty c_n \frac{x^n}{n!}.\tag{0}$$
But
$$
A(x)B(x)^3=\frac{1}{8}(e^{4x}+3e^{2x}+3+e^{-2x})=1+\sum_{n=1}^\infty\left(\frac{4^n+3(2^n)+(-2)^n}{8}\right)\frac{x^n}{n!}.\tag{1}
$$
Comparing (0) and (1) it follows that $c_0 = 1$ (empty word) and $$
c_n = \frac{4^n+3(2^n)+(-2)^n}{8}; \quad( {n\geq 1}).
$$