I write down a string of $k$ letters, where each letter is $X, Y, \text{or } Z.$ The letter $X$ appears an even number of times. How many different sequences of letters could I have written down?
I think I need to start by setting up some cases, and building a recursion from that. I tried but arrived at a really weird form. May I have a start, please?
Let $A_k$ denote the number of sequences of length $k$ with an even number of $X$'s.
For any of the $3^{k-1}$ sequences of length $k-1$, by adding either an $X$ or a $Y$ to the end, you may obtain a sequence with an even number of $X$'s.
Additionally, for each of the $A_{k-1}$ sequences of length $k-1$ with an even number of $X$'s, you may add a $Z$ to the end, to obtain a sequence of length $k$ with an even number of $X$'s.
Thus $A_{k}=3^{k-1}+A_{k-1}$. As $A_0=1$ we have$$A_k=1+1+3+9+\cdots+3^{k-1}=\frac{3^k+1}2.$$