Perfect code 


An \((n,K,2t+1)_q\) code is perfect if parameters \(n\), \(K\), \(t\), and \(q\) are such that the Hamming (a.k.a. sphere-packing) bound \begin{align} \sum_{j=0}^{t}(q-1)^{j}{n \choose j}\leq q^{n}/K \tag*{(1)}\end{align} becomes an equality. In other words, the code's packing radius matches its covering radius.

For example, for a binary \(q=2\) code with one logical bit (\(K=2\)) and \(t=1\), the bound becomes \(n+1 \leq 2^{n-1}\). Perfect codes are those for which balls of Hamming radius \(t\) exactly fill the space of all \(n\) \(q\)-ary strings.

Any perfect linear code is either a repetition code, a Hamming code, or a binary or ternary Golay code [1]. If \(q\) is a prime power, any distance-three code is either a Hamming code or a nonlinear code with the same parameters; see [2; pg. 100] for more details.


  • Covering code — Perfect codes are covering codes with minimum number of codewords




K. Lindström, “All nearly perfect codes are known”, Information and Control 35, 40 (1977) DOI
V. D. Tonchev, "Codes and designs." Concise Encyclopedia of Coding Theory (Chapman and Hall/CRC, 2021) DOI
E. F. Assmus, Jr. and H. F. Mattson, Jr., “Coding and Combinatorics”, SIAM Review 16, 349 (1974) DOI
W. C. Huffman and V. Pless, Fundamentals of Error-Correcting Codes (Cambridge University Press, 2003) DOI
Page edit log

Your contribution is welcome!

on (edit & pull request)

edit on this site

Zoo Code ID: perfect

Cite as:
“Perfect code”, The Error Correction Zoo (V. V. Albert & P. Faist, eds.), 2022.
  title={Perfect code},
  booktitle={The Error Correction Zoo},
  editor={Albert, Victor V. and Faist, Philippe},
Share via:
Twitter | Mastodon |  | E-mail
Permanent link:

Cite as:

“Perfect code”, The Error Correction Zoo (V. V. Albert & P. Faist, eds.), 2022.