// Numbas version: finer_feedback_settings {"name": "Find all words within given Hamming distance", "extensions": ["codewords", "permutations"], "custom_part_types": [], "resources": [], "navigation": {"allowregen": true, "showfrontpage": false, "preventleave": false, "typeendtoleave": false}, "question_groups": [{"pickingStrategy": "all-ordered", "questions": [{"parts": [{"answer": "", "displayAnswer": "{sphere_string}", "customMarkingAlgorithm": "", "extendBaseMarkingAlgorithm": true, "prompt": "
Enter your answer as a list of codewords, separated by commas. For example: 0000, 0001, 0002
.
All words whose Hamming distance from base_word
is radius
.
Number of choices of digit
"}, "sphere_string": {"templateType": "anything", "group": "Ungrouped variables", "definition": "join(map(string(x),x,sphere),', ')", "name": "sphere_string", "description": "The list of words in sphere
, as a string to be used as the displayed answer to the question.
The centre of the ball.
"}, "radius": {"templateType": "anything", "group": "Ungrouped variables", "definition": "random(1..word_length-1)", "name": "radius", "description": "Radius of the Hamming sphere
"}}, "ungrouped_variables": ["word_length", "field_size", "base_word", "radius", "sphere", "sphere_string"], "name": "Find all words within given Hamming distance", "variable_groups": [], "preamble": {"css": "", "js": ""}, "variablesTest": {"condition": "len(sphere)<15 and len(sphere)>3", "maxRuns": 100}, "statement": "Find all words $w \\in \\mathbb{Z}_{\\var{field_size}}^{\\var{word_length}}$ for which $d_\\mathrm{H}(w,\\var{base_word}) = \\var{radius}$.
", "tags": [], "rulesets": {}, "extensions": ["codewords", "permutations"], "type": "question", "metadata": {"licence": "Creative Commons Attribution 4.0 International", "description": "Find all words with given Hamming distance from a given codeword.
"}, "functions": {}, "advice": "Each word $w$ must differ from the word $\\var{base_word}$ in $\\var{radius}$ {pluralise(radius,\"place\",\"places\")}.
\nThere are $\\simplify{comb({word_length},{radius}) = {comb(word_length,radius)}}$ ways of choosing $\\var{radius}$ {pluralise(radius,\"digit\",\"digits\")} to change, and $\\var{field_size}-1 = \\var{field_size-1}$ {pluralise(field_size-1,\"choice\",\"choices\")} for each changed digit.
\nThat means that there are $\\simplify[]{{comb(word_length,radius)}*{field_size-1}^{radius}} = \\var{comb(word_length,radius)*(field_size-1)^radius}$ words $w$ with $d_\\mathrm{H}(w,\\var{base_word}) = \\var{radius}$.
", "contributors": [{"name": "Christian Lawson-Perfect", "profile_url": "https://numbas-editor.mas.ncl.ac.uk/accounts/profile/3/"}, {"name": "Chris Graham", "profile_url": "https://numbas-editor.mas.ncl.ac.uk/accounts/profile/73/"}, {"name": "Christian Lawson-Perfect", "profile_url": "https://numbas.mathcentre.ac.uk/accounts/profile/7/"}]}]}], "contributors": [{"name": "Christian Lawson-Perfect", "profile_url": "https://numbas-editor.mas.ncl.ac.uk/accounts/profile/3/"}, {"name": "Chris Graham", "profile_url": "https://numbas-editor.mas.ncl.ac.uk/accounts/profile/73/"}, {"name": "Christian Lawson-Perfect", "profile_url": "https://numbas.mathcentre.ac.uk/accounts/profile/7/"}]}