// Numbas version: finer_feedback_settings {"name": "Maths and Cryptography Exam Practice", "metadata": {"description": "", "licence": "None specified"}, "duration": 0, "percentPass": 0, "showQuestionGroupNames": false, "shuffleQuestionGroups": false, "showstudentname": true, "question_groups": [{"name": "Set Theory", "pickingStrategy": "all-ordered", "pickQuestions": 1, "questionNames": [""], "variable_overrides": [[]], "questions": [{"name": "Set Operations", "extensions": [], "custom_part_types": [], "resources": ["question-resources/384px-Venn0111.svg.png", "question-resources/384px-Venn0001.svg.png", "question-resources/384px-Venn0110.svg.png", "question-resources/240px-Venn0100.svg.png"], "navigation": {"allowregen": true, "showfrontpage": false, "preventleave": false, "typeendtoleave": false}, "contributors": [{"name": "Daniel Mansfield", "profile_url": "https://numbas.mathcentre.ac.uk/accounts/profile/743/"}, {"name": "Simon Thomas", "profile_url": "https://numbas.mathcentre.ac.uk/accounts/profile/3148/"}, {"name": "Alexander Corner", "profile_url": "https://numbas.mathcentre.ac.uk/accounts/profile/5328/"}], "tags": [], "metadata": {"description": "
Simple exercises introducing the fundamental set operations, and NUMBAS syntax for sets.
", "licence": "Creative Commons Attribution-ShareAlike 4.0 International"}, "statement": "Consider the sets $A = \\var{A}$ and $B = \\var{B}$. Find the union, intersection, and set differences below. Use the NUMBAS syntax set(1,2,3) for $\\left\\{1,2,3\\right\\}$.
The union of two sets is the set of elements from either set
\n$ A \\cup B = \\left\\{ x\\, |\\, x \\in A \\text{ or } x \\in B\\right\\}$
\nWe can think of this as the elements: in $A$ OR in $B$ OR in Both
\nThe intersection of two sets is the set of elements common to both sets
\n$ A \\cap B = \\left\\{ x\\, |\\, x \\in A \\text{ and } x \\in B\\right\\}$
\nWe can think of this as the elements: in $A$ AND in $B$
\nThe difference $A-B$ is the set of elements from $A$ which are not in $B$:
\n$ A - B = \\left\\{ x \\in A |\\, x \\notin B\\right\\}$
\nWe can think of this as the elements: in $A$ but NOT in $B$
\nSimilarly, the difference $B-A$ is the set of elements from $B$ which are not in $A$:
\n$ B - A = \\left\\{ x \\in B |\\, x \\notin A\\right\\}$
\nWe can think of this as the elements: in $B$ but NOT in $A$
\nThe symmetric difference $A \\Delta B$ is the union of the set differences, but it can also be expressed as the union minus the intersection
\n$ A \\Delta B = (A \\cup B) - (A \\cap B)$.
\nWe can think of this as the elements: in $A$ OR in $B$ but NOT in Both.
", "rulesets": {}, "variables": {"listB": {"name": "listB", "group": "Ungrouped variables", "definition": "repeat(random(0..4),4)", "description": "", "templateType": "anything"}, "B": {"name": "B", "group": "Ungrouped variables", "definition": "union(set(listB),set(listN))", "description": "", "templateType": "anything"}, "A": {"name": "A", "group": "Ungrouped variables", "definition": "union(set(listA),set(listN))", "description": "", "templateType": "anything"}, "listN": {"name": "listN", "group": "Ungrouped variables", "definition": "repeat(random(1..9),2)", "description": "", "templateType": "anything"}, "listA": {"name": "listA", "group": "Ungrouped variables", "definition": "repeat(random(5..9),4)", "description": "", "templateType": "anything"}}, "variablesTest": {"condition": "not(listA = listB)", "maxRuns": 100}, "ungrouped_variables": ["listA", "listB", "A", "B", "listN"], "variable_groups": [], "functions": {}, "preamble": {"js": "", "css": ""}, "parts": [{"type": "jme", "useCustomName": false, "customName": "", "marks": 1, "scripts": {"validate": {"script": "try {\n var tree = Numbas.jme.compile(this.studentAnswer);\n var type = Numbas.jme.evaluate(tree,this.question.scope).type;\n \n if ('set' != type) { \n this.giveWarning(\"Your answer must be a set. Use the syntax set(1,2,3) for the set $\\\\left\\\\{1,2,3\\\\right\\\\}$\");\n return false;\n }\n \n return true;\n}\ncatch(e) {\n this.markingComment(e);\n return false;\n}", "order": "instead"}}, "customMarkingAlgorithm": "", "extendBaseMarkingAlgorithm": true, "unitTests": [], "showCorrectAnswer": true, "showFeedbackIcon": true, "variableReplacements": [], "variableReplacementStrategy": "originalfirst", "nextParts": [], "suggestGoingBack": false, "adaptiveMarkingPenalty": 0, "exploreObjective": null, "prompt": "What is the union $A \\cup B$?
", "answer": "{union(A,B)}", "showPreview": true, "checkingType": "absdiff", "checkingAccuracy": 0.001, "failureRate": 1, "vsetRangePoints": 5, "vsetRange": [0, 1], "checkVariableNames": false, "singleLetterVariables": false, "allowUnknownFunctions": true, "implicitFunctionComposition": false, "valuegenerators": []}, {"type": "jme", "useCustomName": false, "customName": "", "marks": 1, "scripts": {"validate": {"script": "try {\n var tree = Numbas.jme.compile(this.studentAnswer);\n var type = Numbas.jme.evaluate(tree,this.question.scope).type;\n \n if ('set' != type) { \n this.giveWarning(\"Your answer must be a set. Use the syntax set(1,2,3) for the set $\\\\left\\\\{1,2,3\\\\right\\\\}$\");\n return false;\n }\n \n return true;\n}\ncatch(e) {\n this.markingComment(e);\n return false;\n}", "order": "instead"}}, "customMarkingAlgorithm": "", "extendBaseMarkingAlgorithm": true, "unitTests": [], "showCorrectAnswer": true, "showFeedbackIcon": true, "variableReplacements": [], "variableReplacementStrategy": "originalfirst", "nextParts": [], "suggestGoingBack": false, "adaptiveMarkingPenalty": 0, "exploreObjective": null, "prompt": "What is the intersection $A \\cap B$?
", "answer": "{intersection(A,B)}", "showPreview": true, "checkingType": "absdiff", "checkingAccuracy": 0.001, "failureRate": 1, "vsetRangePoints": 5, "vsetRange": [0, 1], "checkVariableNames": false, "singleLetterVariables": false, "allowUnknownFunctions": true, "implicitFunctionComposition": false, "valuegenerators": []}, {"type": "jme", "useCustomName": false, "customName": "", "marks": 1, "scripts": {"validate": {"script": "try {\n var tree = Numbas.jme.compile(this.studentAnswer);\n var type = Numbas.jme.evaluate(tree,this.question.scope).type;\n \n if ('set' != type) { \n this.giveWarning(\"Your answer must be a set. Use the syntax set(1,2,3) for the set $\\\\left\\\\{1,2,3\\\\right\\\\}$\");\n return false;\n }\n \n return true;\n}\ncatch(e) {\n this.markingComment(e);\n return false;\n}", "order": "instead"}}, "customMarkingAlgorithm": "", "extendBaseMarkingAlgorithm": true, "unitTests": [], "showCorrectAnswer": true, "showFeedbackIcon": true, "variableReplacements": [], "variableReplacementStrategy": "originalfirst", "nextParts": [], "suggestGoingBack": false, "adaptiveMarkingPenalty": 0, "exploreObjective": null, "prompt": "What is $A\\setminus B$, the set of elements from $A$ which are not in $B$?
", "answer": "{A-B}", "showPreview": true, "checkingType": "absdiff", "checkingAccuracy": 0.001, "failureRate": 1, "vsetRangePoints": 5, "vsetRange": [0, 1], "checkVariableNames": false, "singleLetterVariables": false, "allowUnknownFunctions": true, "implicitFunctionComposition": false, "valuegenerators": []}, {"type": "jme", "useCustomName": false, "customName": "", "marks": 1, "scripts": {"validate": {"script": "try {\n var tree = Numbas.jme.compile(this.studentAnswer);\n var type = Numbas.jme.evaluate(tree,this.question.scope).type;\n \n if ('set' != type) { \n this.giveWarning(\"Your answer must be a set. Use the syntax set(1,2,3) for the set $\\\\left\\\\{1,2,3\\\\right\\\\}$\");\n return false;\n }\n \n return true;\n}\ncatch(e) {\n this.markingComment(e);\n return false;\n}", "order": "instead"}}, "customMarkingAlgorithm": "", "extendBaseMarkingAlgorithm": true, "unitTests": [], "showCorrectAnswer": true, "showFeedbackIcon": true, "variableReplacements": [], "variableReplacementStrategy": "originalfirst", "nextParts": [], "suggestGoingBack": false, "adaptiveMarkingPenalty": 0, "exploreObjective": null, "prompt": "What is $B\\setminus A$, the set of elements from $B$ which are not in $A$?
", "answer": "{B-A}", "showPreview": true, "checkingType": "absdiff", "checkingAccuracy": 0.001, "failureRate": 1, "vsetRangePoints": 5, "vsetRange": [0, 1], "checkVariableNames": false, "singleLetterVariables": false, "allowUnknownFunctions": true, "implicitFunctionComposition": false, "valuegenerators": []}, {"type": "jme", "useCustomName": false, "customName": "", "marks": 1, "scripts": {"validate": {"script": "try {\n var tree = Numbas.jme.compile(this.studentAnswer);\n var type = Numbas.jme.evaluate(tree,this.question.scope).type;\n \n if ('set' != type) { \n this.giveWarning(\"Your answer must be a set. Use the syntax set(1,2,3) for the set $\\\\left\\\\{1,2,3\\\\right\\\\}$\");\n return false;\n }\n \n return true;\n}\ncatch(e) {\n this.markingComment(e);\n return false;\n}", "order": "instead"}}, "customMarkingAlgorithm": "", "extendBaseMarkingAlgorithm": true, "unitTests": [], "showCorrectAnswer": true, "showFeedbackIcon": true, "variableReplacements": [], "variableReplacementStrategy": "originalfirst", "nextParts": [], "suggestGoingBack": false, "adaptiveMarkingPenalty": 0, "exploreObjective": null, "prompt": "What is union of the set differences $(A\\setminus B)\\cup(B\\setminus A)$? This is also called the symmetric difference $A\\Delta B$.
", "answer": "{union(A-B,B-A)}", "showPreview": true, "checkingType": "absdiff", "checkingAccuracy": 0.001, "failureRate": 1, "vsetRangePoints": 5, "vsetRange": [0, 1], "checkVariableNames": false, "singleLetterVariables": false, "allowUnknownFunctions": true, "implicitFunctionComposition": false, "valuegenerators": []}, {"type": "m_n_x", "useCustomName": false, "customName": "", "marks": 0, "scripts": {}, "customMarkingAlgorithm": "", "extendBaseMarkingAlgorithm": true, "unitTests": [], "showCorrectAnswer": true, "showFeedbackIcon": true, "variableReplacements": [], "variableReplacementStrategy": "originalfirst", "nextParts": [], "suggestGoingBack": false, "adaptiveMarkingPenalty": 0, "exploreObjective": null, "prompt": "Match the mathematical expression with its Venn diagram.
\n", "minMarks": 0, "maxMarks": "1", "minAnswers": 0, "maxAnswers": 0, "shuffleChoices": true, "shuffleAnswers": true, "displayType": "radiogroup", "warningType": "none", "showCellAnswerState": true, "choices": ["$A\\cup B$
", "$A \\cap B$
", "$A \\Delta B$
", "$A \\setminus B$
"], "matrix": [["0.25", 0, 0, 0], [0, "0.25", 0, 0], [0, 0, "0.25", 0], [0, 0, 0, "0.25"]], "layout": {"type": "all", "expression": ""}, "answers": ["



The number of attacks on a network port are recorded daily for ten days in a row. These numbers are shown below:
\n$\\var{numbers}$.
", "advice": "The values for the mean, median, and mode are shown below:
\nWhich of the following statements are true?
", "minMarks": 0, "maxMarks": 0, "minAnswers": 0, "maxAnswers": 0, "shuffleChoices": true, "shuffleAnswers": false, "displayType": "radiogroup", "warningType": "none", "showCellAnswerState": true, "markingMethod": "sum ticked cells", "choices": ["Mean < Median", "Median < Mode", "Mode < Mean", "Mean = Median = Mode"], "matrix": "[ \t[if(mean_median,1,0),if(mean_median,0,1)], \t[if(median_mode,1,0),if(median_mode,0,1)], \t[if(mode_mean,1,0),if(mode_mean,0,1)], \t[if(mean_median_mode,1,0),if(mean_median_mode,0,1)], ]", "layout": {"type": "all", "expression": ""}, "answers": ["True", "False"]}], "partsMode": "all", "maxMarks": 0, "objectives": [], "penalties": [], "objectiveVisibility": "always", "penaltyVisibility": "always"}, {"name": "Link Probabilities", "extensions": [], "custom_part_types": [], "resources": ["question-resources/link2.png", "question-resources/link1.png", "question-resources/link5.png"], "navigation": {"allowregen": true, "showfrontpage": false, "preventleave": false, "typeendtoleave": false}, "contributors": [{"name": "Alexander Corner", "profile_url": "https://numbas.mathcentre.ac.uk/accounts/profile/5328/"}], "tags": [], "metadata": {"description": "", "licence": "None specified"}, "statement": "Some short network links are given below, made up of components (a), (b), and (c). The components work independently, so if one fails the others are not affected.
\nThe probability of each component being functional is:
\nIn each part, give all decimal places that you have calculated.
", "advice": "Series:
\nThe probability that the link works is $P(A \\wedge B) = P(A) \\times P(B) = \\var{probA} \\times \\var{probB} = \\simplify{{probA}*{probB}}$.
\nParallel:
\nThe probability that the link works is $P(A \\vee B) = P(A) + P(B) - P(A) \\times P(B) = \\var{probA} + \\var{probB} - \\var{probA} \\times \\var{probB} = \\simplify{{probA} + {probB} - {probA}*{probB}}$.
\nCombined:
\nThe probability that the link works is $P((A \\vee B) \\wedge C) = P(A \\vee B) \\times P(C) = \\simplify{{probA} + {probB} - {probA}*{probB}} \\times \\var{probC} = \\simplify{({probA} + {probB} - {probA}*{probB})*{probC}}$.
", "rulesets": {}, "builtin_constants": {"e": true, "pi,\u03c0": true, "i": true, "j": false}, "constants": [], "variables": {"probA": {"name": "probA", "group": "Ungrouped variables", "definition": "random([0.5,0.6,0.7,0.8,0.9])", "description": "", "templateType": "anything", "can_override": false}, "probB": {"name": "probB", "group": "Ungrouped variables", "definition": "random([0.5,0.6,0.7,0.8,0.9] except probA)", "description": "", "templateType": "anything", "can_override": false}, "probC": {"name": "probC", "group": "Ungrouped variables", "definition": "random([0.5,0.6,0.7,0.8,0.9] except [probA,probB])", "description": "", "templateType": "anything", "can_override": false}, "series": {"name": "series", "group": "Ungrouped variables", "definition": "probA*probB", "description": "", "templateType": "anything", "can_override": false}, "parallel": {"name": "parallel", "group": "Ungrouped variables", "definition": "probA + probB - probA*probB", "description": "", "templateType": "anything", "can_override": false}, "combined": {"name": "combined", "group": "Ungrouped variables", "definition": "parallel*probC", "description": "", "templateType": "anything", "can_override": false}}, "variablesTest": {"condition": "", "maxRuns": 100}, "ungrouped_variables": ["probA", "probB", "probC", "series", "parallel", "combined"], "variable_groups": [], "functions": {}, "preamble": {"js": "", "css": ""}, "parts": [{"type": "numberentry", "useCustomName": true, "customName": "Series Probability", "marks": 1, "scripts": {}, "customMarkingAlgorithm": "", "extendBaseMarkingAlgorithm": true, "unitTests": [], "showCorrectAnswer": true, "showFeedbackIcon": true, "variableReplacements": [], "variableReplacementStrategy": "originalfirst", "nextParts": [], "suggestGoingBack": false, "adaptiveMarkingPenalty": 0, "exploreObjective": null, "prompt": "
The link functions if both of (a) or (b) function. What is the probability that the network link functions?
", "minValue": "series", "maxValue": "series", "correctAnswerFraction": false, "allowFractions": false, "mustBeReduced": false, "mustBeReducedPC": 0, "displayAnswer": "", "showFractionHint": true, "notationStyles": ["plain", "en", "si-en"], "correctAnswerStyle": "plain"}, {"type": "numberentry", "useCustomName": true, "customName": "Parallel Probability", "marks": 1, "scripts": {}, "customMarkingAlgorithm": "", "extendBaseMarkingAlgorithm": true, "unitTests": [], "showCorrectAnswer": true, "showFeedbackIcon": true, "variableReplacements": [], "variableReplacementStrategy": "originalfirst", "nextParts": [], "suggestGoingBack": false, "adaptiveMarkingPenalty": 0, "exploreObjective": null, "prompt": "
The link functions if either of (a) or (b) function, or both. What is the probability that the network link functions?
", "minValue": "parallel", "maxValue": "parallel", "correctAnswerFraction": false, "allowFractions": false, "mustBeReduced": false, "mustBeReducedPC": 0, "displayAnswer": "", "showFractionHint": true, "notationStyles": ["plain", "en", "si-en"], "correctAnswerStyle": "plain"}, {"type": "numberentry", "useCustomName": true, "customName": "Combined Probability", "marks": 1, "scripts": {}, "customMarkingAlgorithm": "", "extendBaseMarkingAlgorithm": true, "unitTests": [], "showCorrectAnswer": true, "showFeedbackIcon": true, "variableReplacements": [], "variableReplacementStrategy": "originalfirst", "nextParts": [], "suggestGoingBack": false, "adaptiveMarkingPenalty": 0, "exploreObjective": null, "prompt": "
The link functions if both of (a) and (c) function, or if (b) and (c) function, or if (a) and (b) and (c) function. What is the probability that the network link functions?
", "minValue": "combined", "maxValue": "combined", "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"}, {"name": "Conditional Probability", "extensions": [], "custom_part_types": [], "resources": [], "navigation": {"allowregen": true, "showfrontpage": false, "preventleave": false, "typeendtoleave": false}, "contributors": [{"name": "Alexander Corner", "profile_url": "https://numbas.mathcentre.ac.uk/accounts/profile/5328/"}], "tags": [], "metadata": {"description": "", "licence": "None specified"}, "statement": "In total you have made $\\var{total}$ observations of events $A$ and $B$. You know that the size of the set $A \\setminus B$ is $\\simplify{{A} - {AandB}}$ and the size of the set $B \\setminus A$ is $\\simplify{{B} - {AandB}}$. The number of observations in the set $A \\cap B$ is $\\var{AandB}$, and the number in $A^c \\cap B^c$ is $\\var{notAnotB}$.
\nYou will be asked to find various probabilities, including conditional probabilities. Drawing a Venn diagram and including the sizes of the relevant areas is useful for this question.
", "advice": "Answers are given as fractions and reduced to their lowest terms where possible. Otherwise, they appear twice.
\nProbability of A
\nThe probability of $A$ is given by $\\frac{\\var{A}}{\\var{total}}=\\simplify{{A}/{total}}$.
\nProbability of B
\nThe probability of $B$ is given by $\\frac{\\var{B}}{\\var{total}}=\\simplify{{B}/{total}}$.
\nProbability of A given B
\nThe probability $P(A|B)$ is given by $\\frac{\\var{AandB}}{\\var{B}}=\\simplify{{AandB}/{B}}$.
\nProbability of B given A
\nThe probability $P(B|A)$ is given by $\\frac{\\var{AandB}}{\\var{A}}=\\simplify{{AandB}/{A}}$.
", "rulesets": {}, "builtin_constants": {"e": true, "pi,\u03c0": true, "i": true, "j": false}, "constants": [], "variables": {"total": {"name": "total", "group": "Ungrouped variables", "definition": "random(800..1000)", "description": "", "templateType": "anything", "can_override": false}, "A": {"name": "A", "group": "Ungrouped variables", "definition": "random(100..400)", "description": "", "templateType": "anything", "can_override": false}, "B": {"name": "B", "group": "Ungrouped variables", "definition": "random(100..400)", "description": "", "templateType": "anything", "can_override": false}, "AandB": {"name": "AandB", "group": "Ungrouped variables", "definition": "random(0..min(A,B))", "description": "", "templateType": "anything", "can_override": false}, "notAnotB": {"name": "notAnotB", "group": "Ungrouped variables", "definition": "total-AorB", "description": "", "templateType": "anything", "can_override": false}, "AorB": {"name": "AorB", "group": "Ungrouped variables", "definition": "A + B - AandB", "description": "", "templateType": "anything", "can_override": false}, "probA": {"name": "probA", "group": "Ungrouped variables", "definition": "A/total", "description": "", "templateType": "anything", "can_override": false}, "probB": {"name": "probB", "group": "Ungrouped variables", "definition": "B/total", "description": "", "templateType": "anything", "can_override": false}, "probBgivA": {"name": "probBgivA", "group": "Ungrouped variables", "definition": "AandB/A", "description": "", "templateType": "anything", "can_override": false}, "probAgivB": {"name": "probAgivB", "group": "Ungrouped variables", "definition": "AandB/B", "description": "", "templateType": "anything", "can_override": false}, "test": {"name": "test", "group": "Ungrouped variables", "definition": "notAnotB < 0", "description": "", "templateType": "anything", "can_override": false}, "test2": {"name": "test2", "group": "Ungrouped variables", "definition": "A - AandB <0", "description": "", "templateType": "anything", "can_override": false}}, "variablesTest": {"condition": "", "maxRuns": 100}, "ungrouped_variables": ["total", "A", "B", "AandB", "notAnotB", "AorB", "probA", "probB", "probBgivA", "probAgivB", "test", "test2"], "variable_groups": [], "functions": {}, "preamble": {"js": "", "css": ""}, "parts": [{"type": "numberentry", "useCustomName": true, "customName": "Probability of A", "marks": 1, "scripts": {}, "customMarkingAlgorithm": "", "extendBaseMarkingAlgorithm": true, "unitTests": [], "showCorrectAnswer": true, "showFeedbackIcon": true, "variableReplacements": [], "variableReplacementStrategy": "originalfirst", "nextParts": [], "suggestGoingBack": false, "adaptiveMarkingPenalty": 0, "exploreObjective": null, "prompt": "Calculate $P(A)$.
", "minValue": "probA", "maxValue": "probA", "correctAnswerFraction": true, "allowFractions": true, "mustBeReduced": false, "mustBeReducedPC": 0, "displayAnswer": "", "showFractionHint": true, "notationStyles": ["plain", "en", "si-en"], "correctAnswerStyle": "plain"}, {"type": "numberentry", "useCustomName": true, "customName": "Probability of B", "marks": 1, "scripts": {}, "customMarkingAlgorithm": "", "extendBaseMarkingAlgorithm": true, "unitTests": [], "showCorrectAnswer": true, "showFeedbackIcon": true, "variableReplacements": [], "variableReplacementStrategy": "originalfirst", "nextParts": [], "suggestGoingBack": false, "adaptiveMarkingPenalty": 0, "exploreObjective": null, "prompt": "Calculate $P(B)$.
", "minValue": "probB", "maxValue": "probB", "correctAnswerFraction": true, "allowFractions": true, "mustBeReduced": false, "mustBeReducedPC": 0, "displayAnswer": "", "showFractionHint": true, "notationStyles": ["plain", "en", "si-en"], "correctAnswerStyle": "plain"}, {"type": "numberentry", "useCustomName": true, "customName": "Probability of A given B", "marks": 1, "scripts": {}, "customMarkingAlgorithm": "", "extendBaseMarkingAlgorithm": true, "unitTests": [], "showCorrectAnswer": true, "showFeedbackIcon": true, "variableReplacements": [], "variableReplacementStrategy": "originalfirst", "nextParts": [], "suggestGoingBack": false, "adaptiveMarkingPenalty": 0, "exploreObjective": null, "prompt": "Calculate $P(A|B)$.
", "minValue": "probAgivB", "maxValue": "probAgivB", "correctAnswerFraction": true, "allowFractions": true, "mustBeReduced": false, "mustBeReducedPC": 0, "displayAnswer": "", "showFractionHint": true, "notationStyles": ["plain", "en", "si-en"], "correctAnswerStyle": "plain"}, {"type": "numberentry", "useCustomName": true, "customName": "Probability of B given A", "marks": 1, "scripts": {}, "customMarkingAlgorithm": "", "extendBaseMarkingAlgorithm": true, "unitTests": [], "showCorrectAnswer": true, "showFeedbackIcon": true, "variableReplacements": [], "variableReplacementStrategy": "originalfirst", "nextParts": [], "suggestGoingBack": false, "adaptiveMarkingPenalty": 0, "exploreObjective": null, "prompt": "Calculate $P(B|A)$.
", "minValue": "probBgivA", "maxValue": "probBgivA", "correctAnswerFraction": true, "allowFractions": true, "mustBeReduced": false, "mustBeReducedPC": 0, "displayAnswer": "", "showFractionHint": true, "notationStyles": ["plain", "en", "si-en"], "correctAnswerStyle": "plain"}], "partsMode": "all", "maxMarks": 0, "objectives": [], "penalties": [], "objectiveVisibility": "always", "penaltyVisibility": "always"}]}, {"name": "Modular Arithmetic", "pickingStrategy": "all-ordered", "pickQuestions": 1, "questionNames": ["", ""], "variable_overrides": [[], []], "questions": [{"name": "ISBN-10", "extensions": [], "custom_part_types": [], "resources": [], "navigation": {"allowregen": true, "showfrontpage": false, "preventleave": false, "typeendtoleave": false}, "contributors": [{"name": "Alexander Corner", "profile_url": "https://numbas.mathcentre.ac.uk/accounts/profile/5328/"}], "tags": [], "metadata": {"description": "", "licence": "None specified"}, "statement": "", "advice": "", "rulesets": {}, "builtin_constants": {"e": true, "pi,\u03c0": true, "i": true, "j": false}, "constants": [], "variables": {"x1": {"name": "x1", "group": "Ungrouped variables", "definition": "random(0..10)", "description": "", "templateType": "anything", "can_override": false}, "x2": {"name": "x2", "group": "Ungrouped variables", "definition": "random(0..10)", "description": "", "templateType": "anything", "can_override": false}, "x3": {"name": "x3", "group": "Ungrouped variables", "definition": "random(0..10)", "description": "", "templateType": "anything", "can_override": false}, "x4": {"name": "x4", "group": "Ungrouped variables", "definition": "random(0..10)", "description": "", "templateType": "anything", "can_override": false}, "x5": {"name": "x5", "group": "Ungrouped variables", "definition": "random(0..10)", "description": "", "templateType": "anything", "can_override": false}, "x6": {"name": "x6", "group": "Ungrouped variables", "definition": "random(0..10)", "description": "", "templateType": "anything", "can_override": false}, "x7": {"name": "x7", "group": "Ungrouped variables", "definition": "random(0..10)", "description": "", "templateType": "anything", "can_override": false}, "x8": {"name": "x8", "group": "Ungrouped variables", "definition": "random(0..10)", "description": "", "templateType": "anything", "can_override": false}, "x9": {"name": "x9", "group": "Ungrouped variables", "definition": "random(0..10)", "description": "", "templateType": "anything", "can_override": false}, "check_digit": {"name": "check_digit", "group": "Ungrouped variables", "definition": "mod(-check,11)", "description": "", "templateType": "anything", "can_override": false}, "parity": {"name": "parity", "group": "Ungrouped variables", "definition": "matrix([10,9,8,7,6,5,4,3,2])", "description": "", "templateType": "anything", "can_override": false}, "digits": {"name": "digits", "group": "Ungrouped variables", "definition": "transpose(matrix([x1,x2,x3,x4,x5,x6,x7,x8,x9]))", "description": "", "templateType": "anything", "can_override": false}, "check": {"name": "check", "group": "Ungrouped variables", "definition": "mod((parity*digits)[0][0],11)", "description": "", "templateType": "anything", "can_override": false}, "x1'": {"name": "x1'", "group": "Ungrouped variables", "definition": "if(x1=10,\"X\",string(x1))", "description": "", "templateType": "anything", "can_override": false}, "x2'": {"name": "x2'", "group": "Ungrouped variables", "definition": "if(x2=10,\"X\",string(x2))", "description": "", "templateType": "anything", "can_override": false}, "x3'": {"name": "x3'", "group": "Ungrouped variables", "definition": "if(x3=10,\"X\",string(x3))", "description": "", "templateType": "anything", "can_override": false}, "x4'": {"name": "x4'", "group": "Ungrouped variables", "definition": "if(x4=10,\"X\",string(x4))", "description": "", "templateType": "anything", "can_override": false}, "x5'": {"name": "x5'", "group": "Ungrouped variables", "definition": "if(x5=10,\"X\",string(x5))", "description": "", "templateType": "anything", "can_override": false}, "x6'": {"name": "x6'", "group": "Ungrouped variables", "definition": "if(x6=10,\"X\",string(x6))", "description": "", "templateType": "anything", "can_override": false}, "x7'": {"name": "x7'", "group": "Ungrouped variables", "definition": "if(x7=10,\"X\",string(x7))", "description": "", "templateType": "anything", "can_override": false}, "x8'": {"name": "x8'", "group": "Ungrouped variables", "definition": "if(x8=10,\"X\",string(x8))", "description": "", "templateType": "anything", "can_override": false}, "x9'": {"name": "x9'", "group": "Ungrouped variables", "definition": "if(x9=10,\"X\",string(x9))", "description": "", "templateType": "anything", "can_override": false}, "ISBN": {"name": "ISBN", "group": "Ungrouped variables", "definition": "x1' + x2' + x3' + x4' + x5' + x6' + x7' + x8' + x9' + \"?\"", "description": "", "templateType": "anything", "can_override": false}}, "variablesTest": {"condition": "", "maxRuns": 100}, "ungrouped_variables": ["x1", "x2", "x3", "x4", "x5", "x6", "x7", "x8", "x9", "check_digit", "parity", "digits", "check", "x1'", "x2'", "x3'", "x4'", "x5'", "x6'", "x7'", "x8'", "x9'", "ISBN"], "variable_groups": [], "functions": {}, "preamble": {"js": "", "css": ""}, "parts": [{"type": "information", "useCustomName": true, "customName": "ISBN-10", "marks": 0, "scripts": {}, "customMarkingAlgorithm": "", "extendBaseMarkingAlgorithm": true, "unitTests": [], "showCorrectAnswer": true, "showFeedbackIcon": true, "variableReplacements": [], "variableReplacementStrategy": "originalfirst", "nextParts": [], "suggestGoingBack": false, "adaptiveMarkingPenalty": 0, "exploreObjective": null, "prompt": "ISBN-10 is an error-correcting code which, until 2007, was used to assign a unique identifier to every published book. It is now superseded by ISBN-13, but here we look at how it works.
\nEach ISBN-10 code is a ten-digit number, using the digits 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, X, where X stands for 10. All calculations are performed modulo 11. E..g, 147676669X.
\nThe last digit is a check digit, which is calculated based on the previous nine digits. Let $x_i$ represent the digit in position $i$ of the ISBN, e.g., in 0131862391 we have $x_1 = 0$, $x_2 = 1$, $x_3 = 3$, etc. Then, for an ISBN $x_1x_2x_3x_4x_5x_6x_7x_8x_9x_{10}$, the following checksum must be satisfied:
\n\\[ 10x_1 + 9x_2 + 8x_3 + 7x_4 + 6x_5 + 5x_6 + 4x_7 + 3x_8 + 2x_9 + 1x_{10} \\equiv 0 \\mod 11.\\]
\nE.g., for 0131862391 we get
\n\\[ (10 \\times 0) + (9 \\times 1) + (8 \\times 3) + (7 \\times 1) + (6 \\times 8) + (5 \\times 6) + (4 \\times 2) + (3 \\times 3) + (2 \\times 9) + (1 \\times 1) = 154 = 14 \\times 11 \\equiv 0 \\mod 11.\\]
"}, {"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": "You are given the incomplete ISBN-10 code $\\var{ISBN}$ and you are required to calculate the check digit, $x_{10}$. Use the information above to calculate this digit, entering 10 if the check digit is 10 (rather than X).
", "minValue": "{check_digit}", "maxValue": "{check_digit}", "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"}, {"name": "Repeated Squaring: Modular Arithmetic", "extensions": [], "custom_part_types": [], "resources": [], "navigation": {"allowregen": true, "showfrontpage": false, "preventleave": false, "typeendtoleave": false}, "contributors": [{"name": "Alexander Corner", "profile_url": "https://numbas.mathcentre.ac.uk/accounts/profile/5328/"}], "tags": [], "metadata": {"description": "", "licence": "None specified"}, "statement": "This question allows you to practice the repeated squaring method which we use to calculate encrypted message values in RSA.
", "advice": "The powers are shown below:
\n$\\var{base} = \\var{base} \\mod \\var{modulus}$,
\n$\\var{base}^2 = \\var{pow2} \\mod \\var{modulus}$,
\n$\\var{base}^4 = \\var{pow2}^2 = \\var{pow4} \\mod \\var{modulus}$,
\n$\\var{base}^8 = \\var{pow4}^2 = \\var{pow8} \\mod \\var{modulus}$,
\n$\\var{base}^16 = \\var{pow8}^2 = \\var{pow16} \\mod \\var{modulus}$,
\n$\\var{base}^32 = \\var{pow16}^2 = \\var{pow32} \\mod \\var{modulus}$.
\nSplit the required power into powers of 2 and then multiply the appropriate values together.
\nIf your power was 59, then you would need to calculate $\\var{base}^{59} = \\var{base}^{32} \\times \\var{base}^{16} \\times \\var{base}^8 \\times \\var{base}^2 \\times \\var{base}^1 \\mod \\var{modulus}$. This would be calculated as:
\n$\\var{pow32} \\times \\var{pow16} \\times \\var{pow8} \\times \\var{pow2} \\times \\var{base} = \\var{fixpow} \\mod \\var{modulus}.$
\n", "rulesets": {}, "builtin_constants": {"e": true, "pi,\u03c0": true, "i": true, "j": false}, "constants": [], "variables": {"modulus": {"name": "modulus", "group": "Ungrouped variables", "definition": "random(100..200)", "description": "", "templateType": "anything", "can_override": false}, "base": {"name": "base", "group": "Ungrouped variables", "definition": "random(50..80)", "description": "", "templateType": "anything", "can_override": false}, "power": {"name": "power", "group": "Ungrouped variables", "definition": "random(33..63)", "description": "", "templateType": "anything", "can_override": false}, "pow2": {"name": "pow2", "group": "Ungrouped variables", "definition": "mod(base^2,modulus)", "description": "", "templateType": "anything", "can_override": false}, "pow4": {"name": "pow4", "group": "Ungrouped variables", "definition": "mod(pow2^2,modulus)", "description": "", "templateType": "anything", "can_override": false}, "pow8": {"name": "pow8", "group": "Ungrouped variables", "definition": "mod(pow4^2,modulus)", "description": "", "templateType": "anything", "can_override": false}, "pow16": {"name": "pow16", "group": "Ungrouped variables", "definition": "mod(pow8^2,modulus)", "description": "", "templateType": "anything", "can_override": false}, "pow32": {"name": "pow32", "group": "Ungrouped variables", "definition": "mod(pow16^2,modulus)", "description": "", "templateType": "anything", "can_override": false}, "binary": {"name": "binary", "group": "Ungrouped variables", "definition": "tobinary(power)", "description": "", "templateType": "anything", "can_override": false}, "mult": {"name": "mult", "group": "Ungrouped variables", "definition": "mod(mod(mod(if(binary[0]=\"1\",pow32,1)*if(binary[1]=\"1\",pow16,1),modulus)*if(binary[2]=\"1\",pow8,1),modulus)*if(binary[3]=\"1\",pow4,1)*if(binary[4]=\"1\",pow2,1)*if(binary[5]=\"1\",base,1),modulus)", "description": "", "templateType": "anything", "can_override": false}, "fixpow": {"name": "fixpow", "group": "Ungrouped variables", "definition": "mod(base^59,modulus)", "description": "", "templateType": "anything", "can_override": false}}, "variablesTest": {"condition": "", "maxRuns": 100}, "ungrouped_variables": ["modulus", "base", "power", "pow2", "pow4", "pow8", "pow16", "pow32", "binary", "mult", "fixpow"], "variable_groups": [], "functions": {}, "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": "Calculate $\\var{base}^2 \\mod \\var{modulus}$.
", "minValue": "pow2", "maxValue": "pow2", "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": "Calculate $\\var{base}^4 \\mod \\var{modulus}$.
", "minValue": "pow4", "maxValue": "pow4", "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": "Calculate $\\var{base}^8 \\mod \\var{modulus}$.
", "minValue": "pow8", "maxValue": "pow8", "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": "Calculate $\\var{base}^{16} \\mod \\var{modulus}$.
", "minValue": "pow16", "maxValue": "pow16", "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": "Calculate $\\var{base}^{32} \\mod \\var{modulus}$.
", "minValue": "pow32", "maxValue": "pow32", "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": "Use your previous calculations to calculate $\\var{base}^\\var{power} \\mod \\var{modulus}$.
", "minValue": "mult", "maxValue": "mult", "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"}]}, {"name": "Basic Ciphers", "pickingStrategy": "all-ordered", "pickQuestions": 1, "questionNames": [""], "variable_overrides": [[]], "questions": [{"name": "Caesar Cipher", "extensions": [], "custom_part_types": [], "resources": ["question-resources/image_hreTKeM.png", "question-resources/image_QiXzMJa.png", "question-resources/image_fNfHwRn.png", "question-resources/image_ESH1Fkk.png", "question-resources/image_k6NDOc1.png", "question-resources/image_lGPa9ZR.png", "question-resources/image_StpjHXy.png", "question-resources/image_K0DXYPm.png", "question-resources/image_zmrWVqr.png", "question-resources/image_LDdYvys.png", "question-resources/image_8axacAg.png", "question-resources/image_aJ5I5mC.png"], "navigation": {"allowregen": true, "showfrontpage": false, "preventleave": false, "typeendtoleave": false}, "contributors": [{"name": "Alexander Corner", "profile_url": "https://numbas.mathcentre.ac.uk/accounts/profile/5328/"}], "tags": [], "metadata": {"description": "A question that will allow students to check their understanding of the Caesar Cipher by encrypting a short message given a random key. May be updated with a decryption task later.
", "licence": "None specified"}, "statement": "This question will allow you to check your understanding of the Caesar Cipher by encrypting a short message given a random key. You may find this website of ten letter words useful for this question.
", "advice": "Recall that plaintext should be entered as lower case and ciphertext should be entered as upper case.
\nSuppose that your word was \"{plaintext}\". Each character of the word \"{plaintext}\" is encrypted separately, using the key $k = \\var{caesar_key}$: $c_i = m_i + k~(\\operatorname{mod} 26)$. We are mapping letters to numbers by their place in the alphabet, so \"a\" corresponds to $0$, \"b\" corresponds to $1$, ..., \"z\" corresponds to $25$.
\nFor example, the first letter of this word (in position $0$) is \"{plaintext0}\", which corresponds to $\\var{ascii_lower[plaintext0]-97}$. So $c_0 = m_0 + k~(\\operatorname{mod} 26) = \\var{ascii_lower[plaintext0]-97} + \\var{caesar_key}~(\\operatorname{mod} 26) = \\var{mod(ascii_lower[plaintext0]-97 + caesar_key,26)}~(\\operatorname{mod} 26)$. This corresponds to \"$\\var{upper(keys(ascii_lower)[mod(ascii_lower[plaintext0]-97 + caesar_key,26)])}$\".
\nWe carry on to do this for each letter, which for the word \"{plaintext}\" would eventually give the ciphertext \"{ciphertext}\".
", "rulesets": {}, "builtin_constants": {"e": true, "pi,\u03c0": true, "i": true}, "constants": [], "variables": {"caesar_key": {"name": "caesar_key", "group": "Ungrouped variables", "definition": "random(1..25)", "description": "", "templateType": "anything", "can_override": false}, "plaintext": {"name": "plaintext", "group": "Ungrouped variables", "definition": "\"pacesetter\"", "description": "", "templateType": "string", "can_override": true}, "plaintext1": {"name": "plaintext1", "group": "Ungrouped variables", "definition": "plaintext[1]", "description": "", "templateType": "anything", "can_override": false}, "plaintext2": {"name": "plaintext2", "group": "Ungrouped variables", "definition": "plaintext[2]", "description": "", "templateType": "anything", "can_override": false}, "plaintext0": {"name": "plaintext0", "group": "Ungrouped variables", "definition": "plaintext[0]", "description": "", "templateType": "anything", "can_override": false}, "plaintext3": {"name": "plaintext3", "group": "Ungrouped variables", "definition": "plaintext[3]", "description": "", "templateType": "anything", "can_override": false}, "plaintext4": {"name": "plaintext4", "group": "Ungrouped variables", "definition": "plaintext[4]", "description": "", "templateType": "anything", "can_override": false}, "plaintext5": {"name": "plaintext5", "group": "Ungrouped variables", "definition": "plaintext[5]", "description": "", "templateType": "anything", "can_override": false}, "plaintext6": {"name": "plaintext6", "group": "Ungrouped variables", "definition": "plaintext[6]", "description": "", "templateType": "anything", "can_override": false}, "plaintext7": {"name": "plaintext7", "group": "Ungrouped variables", "definition": "plaintext[7]", "description": "", "templateType": "anything", "can_override": false}, "plaintext8": {"name": "plaintext8", "group": "Ungrouped variables", "definition": "plaintext[8]", "description": "", "templateType": "anything", "can_override": false}, "plaintext9": {"name": "plaintext9", "group": "Ungrouped variables", "definition": "plaintext[9]", "description": "", "templateType": "anything", "can_override": false}, "ciphertext0": {"name": "ciphertext0", "group": "Ungrouped variables", "definition": "keys(ascii_upper)[ascii_upper_cipher[upper(plaintext0)]-65-13]", "description": "", "templateType": "anything", "can_override": false}, "ascii_lower": {"name": "ascii_lower", "group": "Ungrouped variables", "definition": "dict(\"a\":97,\"b\":98,\"c\":99,\"d\":100,\"e\":101,\"f\":102,\"g\":103,\"h\":104,\"i\":105,\"j\":106,\"k\":107,\"l\":108,\"m\":109,\"n\":110,\"o\":111,\"p\":112,\"q\":113,\"r\":114,\"s\":115,\"t\":116,\"u\":117,\"v\":118,\"w\":119,\"x\":120,\"y\":121,\"z\":122)", "description": "", "templateType": "anything", "can_override": false}, "ascii_upper": {"name": "ascii_upper", "group": "Ungrouped variables", "definition": "dict(\"A\":65,\"B\":66,\"C\":67,\"D\":68,\"E\":69,\"F\":70,\"G\":71,\"H\":72,\"I\":73,\"J\":74,\"K\":75,\"L\":76,\"M\":77,\"N\":78,\"O\":79,\"P\":80,\"Q\":81,\"R\":82,\"S\":83,\"T\":84,\"U\":85,\"V\":86,\"W\":87,\"X\":88,\"Y\":89,\"Z\":90)", "description": "", "templateType": "anything", "can_override": false}, "ascii_upper_cipher": {"name": "ascii_upper_cipher", "group": "Ungrouped variables", "definition": "dict(\"A\":(65 + mod(caesar_key + ascii_upper[\"A\"],26)),\"B\":(65 + mod(caesar_key + ascii_upper[\"B\"],26)),\"C\":(65 + mod(caesar_key + ascii_upper[\"C\"],26)),\"D\":(65 + mod(caesar_key + ascii_upper[\"D\"],26)),\"E\":(65 + mod(caesar_key + ascii_upper[\"E\"],26)),\"F\":(65 + mod(caesar_key + ascii_upper[\"F\"],26)),\"G\":(65 + mod(caesar_key + ascii_upper[\"G\"],26)),\"H\":(65 + mod(caesar_key + ascii_upper[\"H\"],26)),\"I\":(65 + mod(caesar_key + ascii_upper[\"I\"],26)),\"J\":(65 + mod(caesar_key + ascii_upper[\"J\"],26)),\"K\":(65 + mod(caesar_key + ascii_upper[\"K\"],26)),\"L\":(65 + mod(caesar_key + ascii_upper[\"L\"],26)),\"M\":(65 + mod(caesar_key + ascii_upper[\"M\"],26)),\"N\":(65 + mod(caesar_key + ascii_upper[\"N\"],26)),\"O\":(65 + mod(caesar_key + ascii_upper[\"O\"],26)),\"P\":(65 + mod(caesar_key + ascii_upper[\"P\"],26)),\"Q\":(65 + mod(caesar_key + ascii_upper[\"Q\"],26)),\"R\":(65 + mod(caesar_key + ascii_upper[\"R\"],26)),\"S\":(65 + mod(caesar_key + ascii_upper[\"S\"],26)),\"T\":(65 + mod(caesar_key + ascii_upper[\"T\"],26)),\"U\":(65 + mod(caesar_key + ascii_upper[\"U\"],26)),\"V\":(65 + mod(caesar_key + ascii_upper[\"V\"],26)),\"W\":(65 + mod(caesar_key + ascii_upper[\"W\"],26)),\"X\":(65 + mod(caesar_key + ascii_upper[\"X\"],26)),\"Y\":(65 + mod(caesar_key + ascii_upper[\"Y\"],26)),\"Z\":(65 + mod(caesar_key + ascii_upper[\"Z\"],26)))", "description": "", "templateType": "anything", "can_override": false}, "ciphertext1": {"name": "ciphertext1", "group": "Ungrouped variables", "definition": "keys(ascii_upper)[ascii_upper_cipher[upper(plaintext1)]-65-13]", "description": "", "templateType": "anything", "can_override": false}, "ciphertext2": {"name": "ciphertext2", "group": "Ungrouped variables", "definition": "keys(ascii_upper)[ascii_upper_cipher[upper(plaintext2)]-65-13]", "description": "", "templateType": "anything", "can_override": false}, "ciphertext3": {"name": "ciphertext3", "group": "Ungrouped variables", "definition": "keys(ascii_upper)[ascii_upper_cipher[upper(plaintext3)]-65-13]", "description": "", "templateType": "anything", "can_override": false}, "ciphertext4": {"name": "ciphertext4", "group": "Ungrouped variables", "definition": "keys(ascii_upper)[ascii_upper_cipher[upper(plaintext4)]-65-13]", "description": "", "templateType": "anything", "can_override": false}, "ciphertext5": {"name": "ciphertext5", "group": "Ungrouped variables", "definition": "keys(ascii_upper)[ascii_upper_cipher[upper(plaintext5)]-65-13]", "description": "", "templateType": "anything", "can_override": false}, "ciphertext6": {"name": "ciphertext6", "group": "Ungrouped variables", "definition": "keys(ascii_upper)[ascii_upper_cipher[upper(plaintext6)]-65-13]", "description": "", "templateType": "anything", "can_override": false}, "ciphertext7": {"name": "ciphertext7", "group": "Ungrouped variables", "definition": "keys(ascii_upper)[ascii_upper_cipher[upper(plaintext7)]-65-13]", "description": "", "templateType": "anything", "can_override": false}, "ciphertext8": {"name": "ciphertext8", "group": "Ungrouped variables", "definition": "keys(ascii_upper)[ascii_upper_cipher[upper(plaintext8)]-65-13]", "description": "", "templateType": "anything", "can_override": false}, "ciphertext9": {"name": "ciphertext9", "group": "Ungrouped variables", "definition": "keys(ascii_upper)[ascii_upper_cipher[upper(plaintext9)]-65-13]", "description": "", "templateType": "anything", "can_override": false}, "ciphertext": {"name": "ciphertext", "group": "Ungrouped variables", "definition": "join([ciphertext0,ciphertext1,ciphertext2,ciphertext3,ciphertext4,ciphertext5,ciphertext6,ciphertext7,ciphertext8,ciphertext9],\"\")", "description": "", "templateType": "anything", "can_override": false}}, "variablesTest": {"condition": "", "maxRuns": 100}, "ungrouped_variables": ["caesar_key", "plaintext", "plaintext0", "plaintext1", "plaintext2", "plaintext3", "plaintext4", "plaintext5", "plaintext6", "plaintext7", "plaintext8", "plaintext9", "ascii_lower", "ascii_upper", "ascii_upper_cipher", "ciphertext0", "ciphertext1", "ciphertext2", "ciphertext3", "ciphertext4", "ciphertext5", "ciphertext6", "ciphertext7", "ciphertext8", "ciphertext9", "ciphertext"], "variable_groups": [], "functions": {}, "preamble": {"js": "", "css": ""}, "parts": [{"type": "gapfill", "useCustomName": true, "customName": "Word Entry", "marks": 0, "scripts": {}, "customMarkingAlgorithm": "", "extendBaseMarkingAlgorithm": true, "unitTests": [], "showCorrectAnswer": true, "showFeedbackIcon": true, "variableReplacements": [], "variableReplacementStrategy": "originalfirst", "nextParts": [{"label": "Encryption", "rawLabel": "", "otherPart": 1, "variableReplacements": [{"variable": "plaintext", "definition": "interpreted_answer[0]"}], "availabilityCondition": "", "penalty": "", "penaltyAmount": 0, "lockAfterLeaving": false}], "suggestGoingBack": false, "adaptiveMarkingPenalty": 0, "exploreObjective": "Ten-letter Word", "prompt": "Please enter a ten letter word in lower case: [[0]].
", "gaps": [{"type": "patternmatch", "useCustomName": true, "customName": "Plaintext", "marks": "0", "scripts": {}, "customMarkingAlgorithm": "", "extendBaseMarkingAlgorithm": true, "unitTests": [], "showCorrectAnswer": true, "showFeedbackIcon": true, "variableReplacements": [], "variableReplacementStrategy": "originalfirst", "nextParts": [], "suggestGoingBack": false, "adaptiveMarkingPenalty": 0, "exploreObjective": "Ten-letter Word", "answer": "\\[a-z]{10}", "displayAnswer": "E.g., abandonee, fabricator, pacesetter.", "caseSensitive": true, "partialCredit": 0, "matchMode": "regex"}], "sortAnswers": false}, {"type": "gapfill", "useCustomName": true, "customName": "Encryption", "marks": 0, "scripts": {}, "customMarkingAlgorithm": "", "extendBaseMarkingAlgorithm": true, "unitTests": [], "showCorrectAnswer": true, "showFeedbackIcon": true, "variableReplacements": [], "variableReplacementStrategy": "originalfirst", "nextParts": [], "suggestGoingBack": false, "adaptiveMarkingPenalty": 0, "exploreObjective": "Encryption", "prompt": "You are provided with the key $\\var{caesar_key}$ and your ten letter word was \"{plaintext}\". Encrypt your word using the Caesar Cipher, which should be entered in upper case: [[0]].
", "gaps": [{"type": "patternmatch", "useCustomName": true, "customName": "Ciphertext", "marks": 1, "scripts": {}, "customMarkingAlgorithm": "", "extendBaseMarkingAlgorithm": true, "unitTests": [], "showCorrectAnswer": true, "showFeedbackIcon": true, "variableReplacements": [], "variableReplacementStrategy": "originalfirst", "nextParts": [], "suggestGoingBack": false, "adaptiveMarkingPenalty": 0, "exploreObjective": null, "answer": "{ciphertext}", "displayAnswer": "", "matchMode": "exact"}], "sortAnswers": false}], "partsMode": "explore", "maxMarks": 0, "objectives": [{"name": "Ten-letter Word", "limit": 0}, {"name": "Encryption", "limit": 1}], "penalties": [], "objectiveVisibility": "always", "penaltyVisibility": "always", "type": "question"}]}, {"name": "XOR", "pickingStrategy": "all-ordered", "pickQuestions": 1, "questionNames": [], "variable_overrides": [], "questions": []}, {"name": "RSA", "pickingStrategy": "all-ordered", "pickQuestions": 1, "questionNames": [""], "variable_overrides": [[]], "questions": [{"name": "RSA Encryption", "extensions": [], "custom_part_types": [], "resources": [], "navigation": {"allowregen": true, "showfrontpage": false, "preventleave": false, "typeendtoleave": false}, "contributors": [{"name": "Alexander Corner", "profile_url": "https://numbas.mathcentre.ac.uk/accounts/profile/5328/"}], "tags": [], "metadata": {"description": "A question which asks students to encrypt a number using RSA, then to factor a small public key and find the decryption exponent.
", "licence": "None specified"}, "statement": "In this question you will be asked to encrypt a number using the provided RSA public key. You will also be asked to factor the public key and provide the decryption key.
\nThe public key is given by $(n,e) = (\\var{modulus},\\var{key})$.
", "advice": "For larger message sizes and larger encryption exponents, you may need to use some technology to help you, such as the Excel spreadsheet we made in order to repeatedly square and reduce numbers in order to obtain large powers.
\nIn this question we had the message value of $m = \\var{message}$, meaning that we needed to find $m^e = \\var{message}^\\var{key} \\operatorname{mod} \\var{modulus}$. Now $m^e = \\var{message}^\\var{key} = \\var{m_to_e} = \\var{encrypted} \\operatorname{mod} \\var{modulus}$.
\nTo find the private key, we can start by factoring the modulus $n = \\var{modulus}$ into two primes. This should not be difficult since the numbers involved are so low. If we can't spot a sensible factor, then we just have to try dividing the modulus $n$ by prime numbers up to $\\sqrt{n} = \\sqrt{\\var{modulus}} = \\var{sqrt_mod}$ until we find one that divides it exactly: this will be the lower of the two primes. In order to find the decryption exponent $d$, we must use the extended Euclidean algorithm in order to find the value of $d$ such that $de \\equiv 1 \\operatorname{mod} \\varphi(n)$, i.e., $d \\times \\var{key} \\equiv 1 \\operatorname{mod} \\var{totient}$. This works out to be $d = \\var{d_key}$.
", "rulesets": {}, "builtin_constants": {"e": true, "pi,\u03c0": true, "i": true, "j": false}, "constants": [], "variables": {"prime1": {"name": "prime1", "group": "Ungrouped variables", "definition": "random(7,11,13)", "description": "", "templateType": "anything", "can_override": false}, "prime2": {"name": "prime2", "group": "Ungrouped variables", "definition": "random(17,19,23)", "description": "", "templateType": "anything", "can_override": false}, "modulus": {"name": "modulus", "group": "Ungrouped variables", "definition": "prime1*prime2", "description": "", "templateType": "anything", "can_override": false}, "key": {"name": "key", "group": "Ungrouped variables", "definition": "if(mod(totient,3)=0,\n if(mod(totient,5)=0,7,5),3)", "description": "", "templateType": "anything", "can_override": false}, "totient": {"name": "totient", "group": "Ungrouped variables", "definition": "(prime1-1)*(prime2-1)", "description": "", "templateType": "anything", "can_override": false}, "e_check": {"name": "e_check", "group": "Ungrouped variables", "definition": "not(mod(totient,key)=0)", "description": "", "templateType": "anything", "can_override": false}, "d_key": {"name": "d_key", "group": "Ungrouped variables", "definition": "if(prime1=7 and prime2=17,77,\nif(prime1=7 and prime2=19,65,\nif(prime1=7 and prime2=23,53,\nif(prime1=11 and prime2=17,107,\nif(prime1=11 and prime2=19,103,\nif(prime1=11 and prime2=23,147,\nif(prime1=13 and prime2=17,77,\nif(prime1=13 and prime2=19,173,53))))))))", "description": "", "templateType": "anything", "can_override": false}, "message": {"name": "message", "group": "Ungrouped variables", "definition": "random(18..30)", "description": "", "templateType": "anything", "can_override": false}, "encrypted": {"name": "encrypted", "group": "Ungrouped variables", "definition": "mod(message^key,modulus)", "description": "", "templateType": "anything", "can_override": false}, "decrypted": {"name": "decrypted", "group": "Ungrouped variables", "definition": "mod(encrypted^d_key,modulus)", "description": "", "templateType": "anything", "can_override": false}, "decrypt_check": {"name": "decrypt_check", "group": "Ungrouped variables", "definition": "message = decrypted", "description": "", "templateType": "anything", "can_override": false}, "bin_d_key": {"name": "bin_d_key", "group": "Ungrouped variables", "definition": "tobinary(d_key)", "description": "", "templateType": "anything", "can_override": false}, "binlength": {"name": "binlength", "group": "Ungrouped variables", "definition": "len(bin_d_key)", "description": "", "templateType": "anything", "can_override": false}, "d_key8": {"name": "d_key8", "group": "Ungrouped variables", "definition": "if(binlength=6,join([\"00\",bin_d_key],\"\"),if(binlength=7,join([\"0\",bin_d_key],\"\"),bin_d_key))", "description": "", "templateType": "anything", "can_override": false}, "key_check": {"name": "key_check", "group": "Ungrouped variables", "definition": "mod(d_key*key,totient)", "description": "", "templateType": "anything", "can_override": false}, "m_to_e": {"name": "m_to_e", "group": "Ungrouped variables", "definition": "message^key", "description": "", "templateType": "anything", "can_override": false}, "sqrt_mod": {"name": "sqrt_mod", "group": "Ungrouped variables", "definition": "siground(sqrt(modulus),3)", "description": "", "templateType": "anything", "can_override": false}}, "variablesTest": {"condition": "", "maxRuns": 100}, "ungrouped_variables": ["prime1", "prime2", "modulus", "totient", "key", "e_check", "d_key", "message", "encrypted", "decrypted", "decrypt_check", "bin_d_key", "binlength", "d_key8", "key_check", "m_to_e", "sqrt_mod"], "variable_groups": [], "functions": {}, "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": "The message you are to encrypt is $m = \\var{message}$. Encrypt this using the given public key above using the RSA algorithm.
", "minValue": "encrypted", "maxValue": "encrypted", "correctAnswerFraction": false, "allowFractions": false, "mustBeReduced": false, "mustBeReducedPC": 0, "displayAnswer": "", "showFractionHint": true, "notationStyles": ["plain", "en", "si-en"], "correctAnswerStyle": "plain"}, {"type": "gapfill", "useCustomName": false, "customName": "", "marks": 0, "scripts": {}, "customMarkingAlgorithm": "", "extendBaseMarkingAlgorithm": true, "unitTests": [], "showCorrectAnswer": true, "showFeedbackIcon": true, "variableReplacements": [], "variableReplacementStrategy": "originalfirst", "nextParts": [], "suggestGoingBack": false, "adaptiveMarkingPenalty": 0, "exploreObjective": null, "prompt": "Now you are asked to factorise the public key and find the decryption exponent, $d$. The private key is established using two prime numbers, $p$ and $q$. For the purposes of this question, the lower of the two primes will be $p$ and the higher will be $q$. In order to do this, you will have to factorise $n = \\var{modulus}$ and find the primes $p$ and $q$.
\n$p = $[[0]]
\n$q = $[[1]]
\n$\\varphi(n) = $[[3]]
\n$d = $[[2]]
", "gaps": [{"type": "numberentry", "useCustomName": true, "customName": "p", "marks": 1, "scripts": {}, "customMarkingAlgorithm": "", "extendBaseMarkingAlgorithm": true, "unitTests": [], "showCorrectAnswer": true, "showFeedbackIcon": true, "variableReplacements": [], "variableReplacementStrategy": "originalfirst", "nextParts": [], "suggestGoingBack": false, "adaptiveMarkingPenalty": 0, "exploreObjective": null, "minValue": "prime1", "maxValue": "prime1", "correctAnswerFraction": false, "allowFractions": false, "mustBeReduced": false, "mustBeReducedPC": 0, "displayAnswer": "", "showFractionHint": true, "notationStyles": ["plain", "en", "si-en"], "correctAnswerStyle": "plain"}, {"type": "numberentry", "useCustomName": true, "customName": "q", "marks": 1, "scripts": {}, "customMarkingAlgorithm": "", "extendBaseMarkingAlgorithm": true, "unitTests": [], "showCorrectAnswer": true, "showFeedbackIcon": true, "variableReplacements": [], "variableReplacementStrategy": "originalfirst", "nextParts": [], "suggestGoingBack": false, "adaptiveMarkingPenalty": 0, "exploreObjective": null, "minValue": "prime2", "maxValue": "prime2", "correctAnswerFraction": false, "allowFractions": false, "mustBeReduced": false, "mustBeReducedPC": 0, "displayAnswer": "", "showFractionHint": true, "notationStyles": ["plain", "en", "si-en"], "correctAnswerStyle": "plain"}, {"type": "numberentry", "useCustomName": true, "customName": "d", "marks": 1, "scripts": {}, "customMarkingAlgorithm": "", "extendBaseMarkingAlgorithm": true, "unitTests": [], "showCorrectAnswer": true, "showFeedbackIcon": true, "variableReplacements": [], "variableReplacementStrategy": "originalfirst", "nextParts": [], "suggestGoingBack": false, "adaptiveMarkingPenalty": 0, "exploreObjective": null, "minValue": "d_key", "maxValue": "d_key", "correctAnswerFraction": false, "allowFractions": false, "mustBeReduced": false, "mustBeReducedPC": 0, "displayAnswer": "", "showFractionHint": true, "notationStyles": ["plain", "en", "si-en"], "correctAnswerStyle": "plain"}, {"type": "numberentry", "useCustomName": true, "customName": "phi(n)", "marks": 1, "scripts": {}, "customMarkingAlgorithm": "", "extendBaseMarkingAlgorithm": true, "unitTests": [], "showCorrectAnswer": true, "showFeedbackIcon": true, "variableReplacements": [], "variableReplacementStrategy": "originalfirst", "nextParts": [], "suggestGoingBack": false, "adaptiveMarkingPenalty": 0, "exploreObjective": null, "minValue": "totient", "maxValue": "totient", "correctAnswerFraction": false, "allowFractions": false, "mustBeReduced": false, "mustBeReducedPC": 0, "displayAnswer": "", "showFractionHint": true, "notationStyles": ["plain", "en", "si-en"], "correctAnswerStyle": "plain"}], "sortAnswers": false}], "partsMode": "all", "maxMarks": 0, "objectives": [], "penalties": [], "objectiveVisibility": "always", "penaltyVisibility": "always"}]}], "allowPrinting": true, "navigation": {"allowregen": true, "reverse": true, "browse": true, "allowsteps": true, "showfrontpage": true, "navigatemode": "sequence", "onleave": {"action": "none", "message": ""}, "preventleave": true, "typeendtoleave": false, "startpassword": "", "autoSubmit": true, "allowAttemptDownload": false, "downloadEncryptionKey": "", "showresultspage": "oncompletion"}, "timing": {"allowPause": true, "timeout": {"action": "none", "message": ""}, "timedwarning": {"action": "none", "message": ""}}, "feedback": {"enterreviewmodeimmediately": true, "showactualmarkwhen": "always", "showtotalmarkwhen": "always", "showanswerstatewhen": "always", "showpartfeedbackmessageswhen": "always", "showexpectedanswerswhen": "inreview", "showadvicewhen": "inreview", "allowrevealanswer": true, "intro": "These questions give you another source of revision practice. The questions will be similar to those found in the exam, but often will require you to do a bit more working. More questions will be added as we go.
", "end_message": "", "results_options": {"printquestions": true, "printadvice": true}, "feedbackmessages": [], "reviewshowexpectedanswer": true, "showanswerstate": true, "reviewshowfeedback": true, "showactualmark": true, "showtotalmark": true, "reviewshowscore": true, "reviewshowadvice": true}, "diagnostic": {"knowledge_graph": {"topics": [], "learning_objectives": []}, "script": "diagnosys", "customScript": ""}, "contributors": [{"name": "Alexander Corner", "profile_url": "https://numbas.mathcentre.ac.uk/accounts/profile/5328/"}], "extensions": [], "custom_part_types": [], "resources": [["question-resources/384px-Venn0111.svg.png", "/srv/numbas/media/question-resources/384px-Venn0111.svg.png"], ["question-resources/384px-Venn0001.svg.png", "/srv/numbas/media/question-resources/384px-Venn0001.svg.png"], ["question-resources/384px-Venn0110.svg.png", "/srv/numbas/media/question-resources/384px-Venn0110.svg.png"], ["question-resources/240px-Venn0100.svg.png", "/srv/numbas/media/question-resources/240px-Venn0100.svg.png"], ["question-resources/image_hreTKeM.png", "/srv/numbas/media/question-resources/image_hreTKeM.png"], ["question-resources/image_QiXzMJa.png", "/srv/numbas/media/question-resources/image_QiXzMJa.png"], ["question-resources/image_fNfHwRn.png", "/srv/numbas/media/question-resources/image_fNfHwRn.png"], ["question-resources/image_ESH1Fkk.png", "/srv/numbas/media/question-resources/image_ESH1Fkk.png"], ["question-resources/image_k6NDOc1.png", "/srv/numbas/media/question-resources/image_k6NDOc1.png"], ["question-resources/image_lGPa9ZR.png", "/srv/numbas/media/question-resources/image_lGPa9ZR.png"], ["question-resources/image_StpjHXy.png", "/srv/numbas/media/question-resources/image_StpjHXy.png"], ["question-resources/image_K0DXYPm.png", "/srv/numbas/media/question-resources/image_K0DXYPm.png"], ["question-resources/image_zmrWVqr.png", "/srv/numbas/media/question-resources/image_zmrWVqr.png"], ["question-resources/image_LDdYvys.png", "/srv/numbas/media/question-resources/image_LDdYvys.png"], ["question-resources/image_8axacAg.png", "/srv/numbas/media/question-resources/image_8axacAg.png"], ["question-resources/image_aJ5I5mC.png", "/srv/numbas/media/question-resources/image_aJ5I5mC.png"], ["question-resources/link2.png", "/srv/numbas/media/question-resources/link2.png"], ["question-resources/link1.png", "/srv/numbas/media/question-resources/link1.png"], ["question-resources/link5.png", "/srv/numbas/media/question-resources/link5.png"]]}