Let $w_n$ be the number of words (strings) of length $n$ that can be made using the digits {0,1,2,3} with an odd number of twos. Find a recurrence relation for $w_n$ and solve the recurrence. The first few values of $w_n$ are calculated for you:
$w_1 = 1$; 2
$w_2= 6$; 20 21 23 02 12 32
$w_3 = 28$; 200 201 203 210 211 213 230 231 233 222 020 021 023 002 012 032 120 121 123 102 112 132 320 321 323 302 312 332
In this answer $a_n=w_n$.
Let $b_{n}$ denote likely the number of words of length $n$ with an even number of twos.
Then $a_{n}+b_{n}=4^{n}$ and $a_{n+1}=3a_{n}+b_{n}=2a_{n}+4^{n}$.
In order to solve it write down some of them:
$a_{1}=1$
$a_{2}=2.1+4$
$a_{3}=2.2.1+2.4+4^{2}$
$a_{4}=2.2.2.1+2.2.4+2.4^{2}+4^{3}$
A pattern shows up:
$a_{n}=\sum_{k=1}^{n}2^{n-k}4^{k-1}=2^{n-1}\sum_{k=1}^{n}2^{k-1}=2^{n-1}\left(2^{n}-1\right)$
Finally prove by induction that this is correct.