// Numbas version: finer_feedback_settings {"name": "LN01 The L0 Norm", "extensions": [], "custom_part_types": [], "resources": [], "navigation": {"allowregen": true, "showfrontpage": false, "preventleave": false, "typeendtoleave": false}, "question_groups": [{"pickingStrategy": "all-ordered", "questions": [{"name": "LN01 The L0 Norm", "tags": [], "metadata": {"description": "", "licence": "Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International"}, "statement": "
What is the $L^{0}$ norm of the following vectors
", "advice": "The L-zero \"norm\"
\nThe $L^{0}$ norm of a vector is not actually a norm (by the formal definition). However, it is a useful tool with practical usage in computing. It simply counts the number of non-zero elements of a vector. So for example you can set up code that returns \"true\" (=0) and \"false\" (=1) to check if a username and password combination are correct. If they are both correct then the vector would be $(0,0)$ in which case the $L^{0}$ norm would return the value $0$ and the log in would be successful. In all other cases (such as correct username but incorrect password) the $L^{0}$ norm would return a non-zero value and you could use this to ensure the login is unsuccessful.
\nFor more information on norms read (for example) this.
", "rulesets": {}, "extensions": [], "builtin_constants": {"e": true, "pi,\u03c0": true, "i": true, "j": false}, "constants": [], "variables": {"vector1": {"name": "vector1", "group": "Ungrouped variables", "definition": "vector(repeat(random(-2,-1,0,0,0,1,2,3),rowsa))", "description": "", "templateType": "anything", "can_override": false}, "vector2": {"name": "vector2", "group": "Ungrouped variables", "definition": "vector(repeat(random(-2,0,0,0,3),rowsb))", "description": "", "templateType": "anything", "can_override": false}, "answera": {"name": "answera", "group": "Ungrouped variables", "definition": "countnonzero(vector1)", "description": "", "templateType": "anything", "can_override": false}, "answerb": {"name": "answerb", "group": "Ungrouped variables", "definition": "countnonzero(vector2)", "description": "", "templateType": "anything", "can_override": false}, "answerc": {"name": "answerc", "group": "Ungrouped variables", "definition": "answera", "description": "", "templateType": "anything", "can_override": false}, "rowsa": {"name": "rowsa", "group": "Ungrouped variables", "definition": "random(2..5)", "description": "", "templateType": "anything", "can_override": false}, "rowsb": {"name": "rowsb", "group": "Ungrouped variables", "definition": "random(2,3,4)", "description": "", "templateType": "anything", "can_override": false}, "number": {"name": "number", "group": "Ungrouped variables", "definition": "random(-4,5,-6,3,-2,7)", "description": "", "templateType": "anything", "can_override": false}}, "variablesTest": {"condition": "", "maxRuns": 100}, "ungrouped_variables": ["vector1", "vector2", "answera", "answerb", "answerc", "rowsa", "rowsb", "number"], "variable_groups": [], "functions": {"countnonzero": {"parameters": [["vector", "vector"]], "type": "number", "language": "javascript", "definition": "var output = 0;\nvar i;\n let count = 0;\n for (let i = 0; i < vector.length; i++) {\n if (vector[i] !== 0) {\n output++;\n }\n }\n return output;"}}, "preamble": {"js": "", "css": ""}, "parts": [{"type": "numberentry", "useCustomName": false, "customName": "", "marks": 1, "scripts": {}, "customMarkingAlgorithm": "", "extendBaseMarkingAlgorithm": true, "unitTests": [], "showCorrectAnswer": true, "showFeedbackIcon": true, "variableReplacements": [], "variableReplacementStrategy": "originalfirst", "nextParts": [], "suggestGoingBack": false, "adaptiveMarkingPenalty": 0, "exploreObjective": null, "prompt": "$\\var{vector1}$
", "minValue": "answera", "maxValue": "answera", "correctAnswerFraction": false, "allowFractions": false, "mustBeReduced": false, "mustBeReducedPC": 0, "displayAnswer": "", "showFractionHint": true, "notationStyles": ["plain", "en", "si-en"], "correctAnswerStyle": "plain"}, {"type": "numberentry", "useCustomName": false, "customName": "", "marks": 1, "scripts": {}, "customMarkingAlgorithm": "", "extendBaseMarkingAlgorithm": true, "unitTests": [], "showCorrectAnswer": true, "showFeedbackIcon": true, "variableReplacements": [], "variableReplacementStrategy": "originalfirst", "nextParts": [], "suggestGoingBack": false, "adaptiveMarkingPenalty": 0, "exploreObjective": null, "prompt": "$\\var{vector2}$
", "minValue": "answerb", "maxValue": "answerb", "correctAnswerFraction": false, "allowFractions": false, "mustBeReduced": false, "mustBeReducedPC": 0, "displayAnswer": "", "showFractionHint": true, "notationStyles": ["plain", "en", "si-en"], "correctAnswerStyle": "plain"}, {"type": "numberentry", "useCustomName": false, "customName": "", "marks": 1, "scripts": {}, "customMarkingAlgorithm": "", "extendBaseMarkingAlgorithm": true, "unitTests": [], "showCorrectAnswer": true, "showFeedbackIcon": true, "variableReplacements": [], "variableReplacementStrategy": "originalfirst", "nextParts": [], "suggestGoingBack": false, "adaptiveMarkingPenalty": 0, "exploreObjective": null, "prompt": "$\\var{number} \\times \\var{vector1}$
", "minValue": "answerc", "maxValue": "answerc", "correctAnswerFraction": false, "allowFractions": false, "mustBeReduced": false, "mustBeReducedPC": 0, "displayAnswer": "", "showFractionHint": true, "notationStyles": ["plain", "en", "si-en"], "correctAnswerStyle": "plain"}], "partsMode": "all", "maxMarks": 0, "objectives": [], "penalties": [], "objectiveVisibility": "always", "penaltyVisibility": "always", "contributors": [{"name": "Mash Sheffield", "profile_url": "https://numbas.mathcentre.ac.uk/accounts/profile/4679/"}, {"name": "Will Morgan", "profile_url": "https://numbas.mathcentre.ac.uk/accounts/profile/21933/"}], "resources": []}]}], "contributors": [{"name": "Mash Sheffield", "profile_url": "https://numbas.mathcentre.ac.uk/accounts/profile/4679/"}, {"name": "Will Morgan", "profile_url": "https://numbas.mathcentre.ac.uk/accounts/profile/21933/"}]}