A question on restricted permutation Question:
Find the number of $n$-character strings that can be formed using the letters $A,B,C,D$ and $E$ such that each string has an even number of $A's$
I have a solution to this question but its too lengthy(at least to me). Can it be solved in a simpler manner? 
 A: Let $f_n$ be the number of strings with an even number of As, $o_n$ the number of strings with an odd number of As.
You easily derive the recurrences
$f_{n+1}=o_n+4f_n$
and $o_{n+1}=f_n+4o_n$.
(e.g. you get an string of $n+1$ characters and an even number of As by
putting an A behind any string of $n$ characters with an odd number of As
or by putting a non-A behind any string of $n$ characters with an even number of As).
The initial values are $f_1=4$ and $o_1=1$.
Adding the equations gives you $f_{n+1}+o_{n+1}=5(f_n+o_n)$,
which gives you $f_n+o_n=5^n$ (you knew this already, since there are $5^n$ strings with any number of As).
Subtracting the equations gives you $f_{n+1}-o_{n+1}=3(f_n+o_n)$, so $f_n-o_n=3^n$.
This leads to $f_n=\frac{5^n+3^n}{2}$. This is your answer.
A: Exponential generating functions can be used here.
The egf for characters $B,C,D,E$ can be written as $$\left(1+x+\frac{x^2}{2!}+\frac{x^3}{3!}+\ldots\right) = e^x$$
Since no. of $A$'s must be even, its egf is $$\left(1+\frac{x^2}{2!}+\frac{x^4}{4!}+\ldots\right) = \frac{e^x+e^{-x}}{2}$$
The egf for the no. of strings is then:
\begin{align*}
  G(x) &= \left(\frac{e^x+e^{-x}}{2}\right)e^{4x}
\end{align*}
And the number of n-character strings is 
$$\left[\frac{x^n}{n!}\right]G(x) = \frac{5^n+3^n}{2}$$
