Problem: Let $X_1,X_2,\dots$ be independent random variables with $X_i\sim\text{Ber}(\frac{1}{2})$. Let $Y_i=\max(X_i,X_{i+1})$ and $Z_n=\sum_{i=1}^{n}Y_i$. Find $\text{E}(Z_n)$ and $\text{Var}(Z_n)$.
My solution: We have $$P(Y_i=1)=P(\max(X_i,X_{i+1})=1)=1-P(\max(X_i,X_{i+1})=0)=1-P(X_i=0,X_{i+1}=0)=$$ $$1-P(X_i=0)P(X_{i+1}=0)=1-\frac{1}{2}\cdot\frac{1}{2}=\frac{3}{4},$$ hence $Y_i\sim\text{Ber}(\frac{3}{4})$, which gives $\text{E}(Y_i)=\frac{3}{4}$. We thus get $$\text{E}(Z_n)=\text{E}\left(\sum_{i=1}^{n}Y_i\right)=\sum_{i=1}^{n}\text{E}(Y_i)=\sum_{i=1}^{n}\frac{3}{4}=\frac{3n}{4}.$$ We have $\text{Var}(Y_i)=\frac{3}{4}(1-\frac{3}{4})=\frac{3}{4}\cdot\frac{1}{4}=\frac{3}{16}$. Let $1\leq i<j\leq n$. If $|i-j|>1$ then $Y_i=\max(X_i,X_{i+1}),Y_j=\max(X_j,X_{j+1})$ and $i,i+1,j,j+1$ are all distinct, and therefore $Y_i,Y_j$ are independent, and in particular $\text{Cov}(Y_i,Y_j)=0$. If $|i-j|=1$ then $$P(Y_iY_j=1)=1-P(Y_iY_j=0)=1-(P(Y_i=0)+P(Y_j=0)-P(Y_i=0,Y_j=0))=$$ $$1-\left(\left(1-\frac{3}{4}\right)+\left(1-\frac{3}{4}\right)-P(\max(X_i,X_j)=0,\max(X_j,X_{j+1})=0)\right)=$$ $$1-\left(\frac{1}{2}-P(X_i=0,X_j=0,X_{j+1}=0)\right)=1-\left(\frac{1}{2}-\left(\frac{1}{2}\right)^3\right)=\frac{5}{8}.$$ Hence $Y_iY_j\sim\text{Ber}(\frac{5}{8})$ which gives $\text{E}(Y_iY_j)=\frac{5}{8}$ so that $$\text{Cov}(Y_i,Y_j)=\text{E}(Y_iY_j)-\text{E}(Y_i)\text{E}(Y_j)=\frac{5}{8}-\frac{3}{4}\cdot\frac{3}{4}=\frac{1}{16}.$$ We finally get $$\text{Var}(Z_n)=\text{Var}\left(\sum_{i=1}^{n}Y_i\right)=\sum_{i=1}^{n}\text{Var}(Y_i)+2\sum_{1\leq i<j\leq n}\text{Cov}(Y_i,Y_j)=$$ $$\sum_{i=1}^{n}\frac{3}{16}+2\sum_{i=1}^{n-1}\text{Cov}(Y_i,Y_{i+1})=\frac{3n}{16}+2(n-1)\frac{1}{16}=\frac{5n-2}{16}.$$
Is my solution correct?
Edit: I don't know if my solution is correct because the answer provided (just a final answer no explanation) said that $\text{E}(Z_n)=\frac{3n}{4}$ (which I also got), but $\text{Var}(Z_n)=\frac{13n-10}{16}$. I can't find anything wrong with my solution, but I'm not sure.
Another edit: I understand my error. I used the inclusion-exclusion principle by treating the random variables like numbers (in which case what I wrote would be true), but random variables are functions so it doesn't work (we may have $fg=0$ but $f\neq 0$ and $g\neq 0$). @NN2 said that $P(Y_iY_{i+1}=0)=\frac{1}{8}$. How can we prove this?