"Let $C$ be a linear code over $Z_2$. Let $C^+$ be the subset of $C$ consisting of those elements of $C$ with even weight. Show that $C^+$ is an additive subgroup of $C$."
It's an exercise from A course in group theory, J. Humphreys, chapter 6. The solution says:
"Suppose that $c$ and $d$ are codewords of even weights, and that $c$ and $d$ agree in $k$ coordinates. The vector $c+d$ has weight $(weight(c)-k)+(weight(d)-k)$ and this is an even integer."
I don't get why that's the weight for $c+d$.
Let $I_c$ be the set of coordinates of non-zero elements of $c$, $I_d$ the set of coordinates of non-zero elements of $d$, and $K$ the set of coordinates on which $c$ and $d$ agree; $c+d$ has non-zero elements precisely in those coordinates where $c$ and $d$ disagree, i.e., those in the symmetric difference $I_c\mathop{\triangle}I_d$. Let $n$ be the length of the code; then
$$\operatorname{weight}(c+d)=|I_c\mathop{\triangle}I_d|=n-|K|=n-k\,.$$
Now
$$\begin{align*} \operatorname{weight}(c)+\operatorname{weight}(d)&=|I_c|+|I_d|\\ &=|I_c\cup I_d|+|I_c\cap I_d|\\ &=|I_c\mathop{\triangle}I_d|+2|I_c\cap I_d|\\ &=n-k+2|I_c\cap I_d|\,. \end{align*}$$
Let $k'=|I_c\cap I_d|$; then
$$\begin{align*} \big(\operatorname{weight}(c)-k'\big)+\big(\operatorname{weight}(d)-k'\big)&=n-k\\ &=\operatorname{weight}(c+d)\,. \end{align*}$$
In general $k'$ need not be equal to $k$: $k'$ is the number of coordinates in which $c$ and $d$ are both $1$, while $k$ is the number on which $c$ and $d$ agree. Thus, the expression for the weight of $c+d$ given in the solution appears to be wrong, but we do still have
$$\operatorname{weight}(c+d)=\big(\operatorname{weight}(c)-k'\big)+\big(\operatorname{weight}(d)-k'\big)$$
and hence
$$\operatorname{weight}(c+d)=\operatorname{weight}(c)+\operatorname{weight}(d)-2k'\,,\tag{1}$$
which is good enough: by hypothesis $\operatorname{weight}(c)$ and $\operatorname{weight}(d)$ are even, and $2k'$ is even, so the righthand side of $(1)$ is even, and $c+d\in C^+$, as desired.