I'm doing exercises in Charles C. Pinter's book A Book of Abstract Algebra and I'm unable to solve problem 7 in section H of chapter 5 (subgroups). I think that there is a solution on this site but it's beyond my knowledge (Proving that number of codes with even weight is the same as number of codes with odd weight for a specific code book).
The question is to prove the following claim:
In any group code, either all the words have even weight, or half the words have even weight and half the words have odd weight.
This question depends on the solution to the previous problem in which the reader is asked to prove properties (evenness and oddness) of the sums of code words. I have done these without any problem. The full chapter is available at http://www2.southeastern.edu/Academics/Faculty/talwis/Teaching/Math370(Chap5).pdf
I've tried to take advantage of some property that guarantees that the weight of all words is either even or odd (I could elaborate).
Any help will be gratefully received.
PK
The following answer is based on the helpful comment by Jyrki Lahtonen.
Consider a group code $C$. Let $C$ have at least one codeword $x$ of odd weight. We want to show that for any $y$, we can construct a subgroup $\{e, x, y, z=x+y\}$ with half the codewords of even weight and half of odd weight. We denote weight of $x$ by $w(x)$.
In the preceding question (in the exercises), the student is asked to show that for $w(x)$ even, $w(y)$ even, $w(u)$ and $w(z)$ odd that $w(x+y)$ and $w(u+z)$ are even and $w(x+z)$ is odd.
First, for any codeword $x = (a_1,a_2,\ldots,a_n)$, $a_i \in \{0,1\} = <\mathbb{Z}_2,+>$
$$x = x^{-1}.$$
Therefore, $\{e, x, y, z=x+y\}$ is a subgroup because
$$z + z^{-1} = e$$ $$(x + y) + z^{-1} = e$$ $$(x + y)^{-1} + (x + y) + z^{-1} = (x + y)^{-1} + e$$ $$z^{-1} = (y + x)^{-1}$$
because $+$ is commutative. Finally,
$$z^{-1} = x^{-1} + y^{-1} = x + y = z,$$
as required.
Now, taking $w(e) = 0$ to be even let us suppose that $w(y)$ is even.
If $w(y)$ is even then $w(z) = w(x + y)$ is odd and the subgroup $\{e, x, y, z\}$ has two codewords of even weight $(e, y)$ and two of odd weight $(x, z)$. Now suppose that $w(y)$ is odd then $w(z)$ is even and we now have two codewords of even weight $(e, z)$ and two of odd weight $(x, y)$. Therefore, for $w(x)$ odd, all subgroups have half the codewords of even weight and half of odd weight.
On the other hand, if there is no codeword of odd weight then all codewords must be of even weight (because there is no way to get odd weights from even weights). QED