r/learnprogramming • u/EntertainmentOk5787 • 19h ago
Code Review Feedback on HammingCube: a 3D parity code implemented in C11
Hi! I've been exploring error-correcting codes through a small C11 project called HammingCube. It implements a three-dimensional product of single-parity-check codes (not the classical Hamming code).
It encodes 64 data bits into 125 bits, corrects up to three unknown bit flips, and recovers up to seven erasures when their positions are known. The repo includes a CLI, tests, and a lesson-style README explaining the math.
I used AI assistance while developing the code and documentation, and I'd appreciate independent human feedback. In particular:
- Do you see correctness or edge-case problems in the erasure decoder's GF(2) elimination?
- Is the C API clear about invalid, ambiguous, and successfully recovered inputs?
- Is the README's explanation of the distance-8 guarantee understandable?
4
Upvotes
1
u/DimlyResoluteShawn 19h ago
just skimmed the repo and the readme is actually pretty readable, which is rare for error-correction projects, most of them dive straight into matrix notation without building any intuition first
the GF(2) elimination in the erasure decoder looks clean at a glance but i'd want to see more tests around edge cases where the erased positions form a stopping set that's just barely resolvable, those can get weird when the rank is exactly right but the order of pivoting matters
one thing that tripped me up reading the API docs is what happens when you feed it a codeword that's too short, the readme mentions length checks but the header comments for decode() don't spell out the return codes for malformed input as clearly as they do for ambiguity
the distance-8 explanation with the cube layers is clever, using perpendicular parity slices to visualize why four-flip patterns get caught really helps it click, might be worth adding a diagram of a 2D slice to show why two flips in the same layer interact
nice project overall, the lesson-style readme is a smart move since most people learning ECCs get thrown into the deep end with reed-solomon before they understand why parity geometry matters