Let be an error-correcting code consisting of codewords,in which each codeword consists of letters taken from an alphabet of length , and every two distinct codewords differ in at least places. Then is said to be perfect if for every possible word of length with letters in , there is a unique code word in in which at most letters of differ from the corresponding letters of .
It is straightforward to show that is perfect if
If is a binary linear code, then and , where is the number of generators of , in which case is perfect if
Hamming codes and the Golay code are the only nontrivial examples of perfect codes.