Probabilities - Traffic Light problem Exercise :
Let it be that on a road trip, the probability of a traffic light having the same color as the previous one, is $p$. If the first traffic light is red with probability $a$ and green with $1-a$, calculate the probability of the third traffic light being green.
Attempt :
Let $R$ be the event of the traffic light being red and $R^c$  the event of the traffic light being green.
Then, for the first traffic light, it is :
$$P(R) = a$$
$$P(R^c) = 1-a$$
Also, let $S$ be the event of the next traffic light having the same color as the previous one. So :
$$P(S) = p$$
Now, to me it seems like it could be something involving Bayes Theorem, especially because we have $3$ traffic lights to check, which goes perfect with the denominator of Bayes, but I really cannot see how to continue on solving this one, basically I do not know how to start and choose between each case (green/red). I would really appreciate a thorough explanation/solution.
 A: This actually has nothing to do with Bayes' theorem.  Let the probability that the $n$th traffic light is red be $a_n$.  Then we have $a_1 = a$.  To obtain a recursive relation for $a_n$, we have two cases: either the previous light is red (probability $a_{n-1}$, and then probability $p$ that the $n$th light is also red), or the previous light is green (probability $1-a_{n-1}$, and then probability $1-p$ that the $n$th light changes to red).  This yields $$a_n = pa_{n-1} + (1-p)(1-a_{n-1}).$$
We now have a recursive relation which we can use to solve for $a_3$ by working up from $a_1$.
Note: your problem is an example of what's called a Markov Chain.  You can read more about it here.
A: This problem is small enough to be solved by enumerating all possibilities.
Hint: Let $X_{i}$ be the color ($r$ or $g$) of the $i$-th traffic light.
Then,
\begin{multline*}
\mathbb{P}(X_{3}=g)=\mathbb{P}(X_{1}X_{2}X_{3}=rrg)+\mathbb{P}(X_{1}X_{2}X_{3}=rgg)\\+\mathbb{P}(X_{1}X_{2}X_{3}=grg)+\mathbb{P}(X_{1}X_{2}X_{3}=ggg)
 %& =ap\left(1-p\right)+a\left(1-p\right)p+\left(1-a\right)\left(1-p\right)^{2}+\left(1-a\right)p^{2}\\
 %& =2ap\left(1-p\right)+\left(1-a\right)\left(1-p\right)^{2}+\left(1-a\right)p^{2}
\end{multline*}
Can you figure out the rest?
A: Yes, but watching Bayes the easy way, just separate the cases and put a probability to each them:
$$P=ap(1-p)+a(1-p)p+(1-a)pp+(1-a)(1-p)(1-p)\\
=1+4ap-4ap^2+2p^2-2p-a$$
A: P(G3)=P(R1R2G3)+P(R1G2G3)+P(G1R2G3)+P(G1G2G3)
=ap (1-p)+a (1-p)p+(1-a)(1-p)p+(1-a)p^2
Since R1,R2 ,R3, G1 , G2 , G3 are Independent events. 
