# Find variance of happy people sitting at $n$ regular polygon table

Let table has shape of $n$ regular polygon and at each side is sitting one person. Each person is flipping a fair coin once (results of $n$ independent tosses are independent). Person is happy iff he and his neighbours flips a head. Let $X$ means amount of happy people. Find $Var(X)$.

My attempt:

Let $X_i=1$ if $i$-th person is happy and $0$ otherwise then $X=X_1+X_2+…+X_n$ then $Var(X)=Var(X_1+…+X_n)=Var(X_1)+…+Var(X_n)+2\cdot\displaystyle\sum_{i<j}Cov(X_i,X_j)$ we have $Var(X_i)=E(X_i^2)-(E(X_i))^2=1^2*P(X_i=1)+0^2*P(X_i=0)-(1*P(X_i=1)+0*P(X_i=0))^2=\frac{1}{8}-\frac{1}{64}=\frac{7}{64}$

so $Var(X_1)+…+Var(X_n)=\frac{7n}{64}$ and $Cov(X_i,X_j)=E(X_iX_j)-E(X_i)E(X_j)$ but if $i,j$ don't have common neighbours then $X_i,X_j$ are independent so $Cov(X_i,X_j)=0$ if $i,j$ have one common neighbour then $E(X_iX_j)=\frac{1}{32}$(since 5 people need to have head) if $i,j$ are neighbours then $E(X_iX_j)=\frac{1}{16}$(since $4$ people need to have head) thus $2\cdot\displaystyle\sum_{i<j}Cov(X_i,X_j)=\frac{n}{8}$ hence $Var(X)=\frac{15n}{64}$

is my reasoning correct ? I'm not sure about fragment with covariances. Thanks in advance

The analysis is structurally correct. Some details (and the answer) change in the cases $n=3$ and $n=4$. Let $n\ge 5$.
For the sum $\sum_{i,j}\text{Cov}(X_i,X_j)$, there are $2n$ ordered pairs with $E(X_iX_j)=\frac{1}{16}$, and $2n$ with $E(X_iX_j)=\frac{1}{32}$, for a total of $\frac{3n}{16}$. From this we must subtract $\frac{4n}{64}$ for the $E(X_i)E(X_j)$. That agrees with your $\frac{n}{8}$ for which some calculation details were omitted.