Count the Hamming distance between words, find the minimum distance of a code, and say what that distance detects and corrects.
Hardware context: The grant logger of an eight-way arbiter and the cursor logic of a UTF-8 serial terminal. Measure the distances of candidate codes for a noisy control wire.
A team is choosing a code for four commands on a noisy control wire. Before choosing, they want to know how far apart the candidate codewords are and how many flipped bits each candidate survives.
This is an Implement problem with no logic to write. Work out each answer and write it into the answer module as one decimal literal. The first three constants are worked examples.
The check compares every constant with the right value and names the first one that is wrong.
Signals in the Timeline
| Signal | Width | Role |
|---|---|---|
question | 8 | input of each check |
Full specification
| Constant | What to write |
|---|---|
| DIST_A | The distance between 1010_1010 and 1010_0101 (their XOR has four 1s). |
| MIN_PARITY3 | The minimum distance of the 3-bit even-parity code 000, 011, 101, 110. |
| CORNERS_5 | How many corners a 5-cube has (one per 5-bit word). |
| DIST_B | The distance between 1100_0011 and 0011_1100. |
| DIST_C | The distance between 0111 and 1110. |
| MIN_Q | The minimum distance of the code 0000_0000, 0000_1111, 1111_0000, 1111_1111. |
| DETECT_Q | How many flipped bits that code always detects. |
| CORRECT_Q | How many flipped bits that code always corrects. |
| EDGES_4 | How many edges a 4-cube has. |
| NEIGHBOURS_6 | How many 6-bit words are at distance 1 from 101100. |
Write each answer as one literal. The check refuses operators and function calls.
Examples
Example 1
Worked Example: A Distance- Input
the distance between 1010_1010 and 1010_0101 (their XOR has four 1s)
- Output
dist_a = 4
The XOR is 0000_1111, with four 1s, so the distance is 4. This constant is already filled in.
Example 2
Worked Example: A Minimum Distance- Input
the minimum distance of the 3-bit even-parity code 000, 011, 101, 110
- Output
min_parity3 = 2
Every pair of these four words differs in two bits, so the minimum distance is 2. This constant is already filled in.
Example 3
Worked Example: Corners- Input
how many corners a 5-cube has (one per 5-bit word)
- Output
corners_5 = 32
A 5-cube has one corner per 5-bit word: 2^5 = 32. This constant is already filled in.
Constraints and Contract
- Keep the module name answer and the names of the constants.
- Every answer is a whole number from 0 to 64.
Hints
Hint 1
XOR the two words and count the 1s.
Hint 2
For a minimum distance, try every pair of codewords and keep the smallest distance.
Hint 3
An n-cube has 2^n corners and n edges at every corner. Each edge joins two corners.
What the grader checks: The check reads ten constants and compares each with a value computed in JavaScript. Before that, a source rule refuses any answer that is not one literal.
10 checks on Icarus · browser samples / server checks. Run the examples first, then check the full regression. Full checks use the server judge. Downloads contain public samples only. A passing result establishes the tested cases, not a proof for all possible inputs.
See all 3 steps and the final capstone