### On a Class of Constant Weight Codes

#### Abstract

For any odd prime power $q$ we first construct a certain non-linear binary code $C(q,2)$ having $(q^2-q)/2$ codewords of length $q$ and weight $(q-1)/2$ each, for which the Hamming distance between any two distinct codewords is in the range $[q/2-3\sqrt q/2,\ q/2+3\sqrt q/2]$ that is, 'almost constant'. Moreover, we prove that $C(q,2)$ is distance-invariant. Several variations and improvements on this theme are then pursued. Thus, we produce other classes of binary codes $C(q,n)$, $n\geq 3$, of length $q$ that have 'almost constant' weights and distances, and which, for fixed $n$ and big $q$, have asymptotically $q^n/n$ codewords. Then we prove the possibility of extending our codes by adding the complements of their codewords. Also, by using results on Artin $L-$series, it is shown that the distribution ofthe $0$'s and $1$'s in the codewords we constructed is quasi-random. Our construction uses character sums associated with the quadratic character $\chi$ of $F_{q^n}$ in which the range of summation is $F_q$. Relations with the duals of the double error correcting BCH codes and the duals of the Melas codes are also discussed.