// Numbas version: exam_results_page_options {"name": "Hamming's square code ", "extensions": ["codewords", "permutations"], "custom_part_types": [], "resources": [], "navigation": {"preventleave": false, "showfrontpage": false, "allowregen": true}, "question_groups": [{"pickingStrategy": "all-ordered", "questions": [{"name": "Hamming's square code ", "extensions": ["codewords", "permutations"], "variablesTest": {"condition": "", "maxRuns": 100}, "ungrouped_variables": ["num_codewords", "original_words", "encoded_original_words", "error_positions", "received_words", "original", "received"], "advice": "

Since we are using the Hamming square code, each encoded code word is of length \$9\$. We received \$18\$ digits, so we have \$2\$ words to check and decode, \$\\var{received_words[0]}\$ and \$\\var{received_words[1]}\$.

\n

\n

Put this word into a square array.

\n

\n

Since we know that at most one error has occurred we can decode as follows:

\n

\n

\n

Put this word into a square array.

\n

\n

Since we know that at most one error has occurred we can decode as follows:

\n

\n

Putting these decoded messages together, we obtain \$\\var{original}\$ as the answer.

", "tags": [], "parts": [{"sortAnswers": false, "unitTests": [], "marks": 0, "type": "gapfill", "customMarkingAlgorithm": "", "extendBaseMarkingAlgorithm": true, "variableReplacements": [], "scripts": {}, "prompt": "

Assuming that the received message contains at most one error per codeword, correct any errors, and then decode to find the original binary string.

\n

Original message: [[0]]

\n

", "variableReplacementStrategy": "originalfirst", "showCorrectAnswer": true, "showFeedbackIcon": true, "gaps": [{"displayAnswer": "{string(original)}", "unitTests": [], "marks": "2", "type": "patternmatch", "customMarkingAlgorithm": "", "extendBaseMarkingAlgorithm": true, "variableReplacements": [], "answer": "\\s*{string(original)}\\s*", "matchMode": "regex", "scripts": {}, "variableReplacementStrategy": "originalfirst", "showCorrectAnswer": true, "showFeedbackIcon": true}]}], "rulesets": {}, "variables": {"received": {"group": "Ungrouped variables", "name": "received", "templateType": "anything", "description": "

", "definition": "concat(received_words)"}, "error_positions": {"group": "Ungrouped variables", "name": "error_positions", "templateType": "anything", "description": "

Positions of errors in the received (encoded) code words

", "definition": "repeat(random(0..8),num_codewords)"}, "encoded_original_words": {"group": "Ungrouped variables", "name": "encoded_original_words", "templateType": "anything", "description": "

The original words, encoded using the square code

", "definition": "map(hamming_square_encode(word),word,original_words)"}, "num_codewords": {"group": "Ungrouped variables", "name": "num_codewords", "templateType": "number", "description": "

Number of words in the message

", "definition": "2"}, "original": {"group": "Ungrouped variables", "name": "original", "templateType": "anything", "description": "

The original message

", "definition": "concat(original_words)"}, "original_words": {"group": "Ungrouped variables", "name": "original_words", "templateType": "anything", "description": "

Randomly chosen distinct codewords, except `0000`

", "definition": "shuffle(allwords(4,2) except codeword(\"0000\",2))[0..num_codewords]"}, "received_words": {"group": "Ungrouped variables", "name": "received_words", "templateType": "anything", "description": "

The received words, with errors applied

", "definition": "map(\n error(encoded_original_words[j],error_positions[j]),j,0..(num_codewords-1)\n)"}}, "contributors": [{"profile_url": "https://numbas-editor.mas.ncl.ac.uk/accounts/profile/3/", "name": "Christian Lawson-Perfect"}, {"profile_url": "https://numbas.mathcentre.ac.uk/accounts/profile/7/", "name": "Christian Lawson-Perfect"}], "functions": {"error_description": {"type": "string", "language": "javascript", "parameters": [["word", "codeword"]], "definition": "var ordinals = [\"first\",\"second\"];\nvar digits = word.digits.slice();\nvar sentences = [];\n\nvar n = 3;\n\nvar row_error;\nvar column_error;\nfor(var i=0;iCorrect an error in a received message which was encoded using Hamming's square code

"}, "type": "question", "statement": "

A binary string was encoded using Hamming's square code, and then transmitted.

\n