// Numbas version: exam_results_page_options {"name": "Caesar cipher", "extensions": [], "custom_part_types": [], "resources": [], "navigation": {"allowregen": true, "showfrontpage": false, "preventleave": false, "typeendtoleave": false}, "question_groups": [{"pickingStrategy": "all-ordered", "questions": [{"name": "Caesar cipher", "tags": [], "metadata": {"description": "

This question asks students to decrypt a message using a simple Caesar cipher, without giving them the key.

", "licence": "Creative Commons Attribution-ShareAlike 4.0 International"}, "statement": "

Caesar wants to organise a secret meeting with Marc Anthony. He sends Marc-Antony the secret message {ciphertext} using a shift cipher. Where do Caesar and Marc Anthony meet (enter your answer in capital letters)?

", "advice": "

We do not have the key to decrypt the message, so we need to try every possible key and choose the answer that is intelligible.

\n

To apply a key $k$ to the string, each letter $x$ is substituted with $x+k\\pmod{26}$, where $x$ is the place of the letter in the alphabet. This gives us the strings {advice}

\n

Of those the only one that makes sense is the one for $k=\\var{26-shift}$, {plaintext}. Therefore this is where Caesar and Marc-Anthony will meet.

", "rulesets": {}, "extensions": [], "builtin_constants": {"e": true, "pi,\u03c0": true, "i": true}, "constants": [], "variables": {"cipher": {"name": "cipher", "group": "Ungrouped variables", "definition": "map(mod(x+shift,26),x,ordinalfromletter(plaintext))", "description": "", "templateType": "anything", "can_override": false}, "shift": {"name": "shift", "group": "Ungrouped variables", "definition": "random(1 .. 25#1)", "description": "", "templateType": "randrange", "can_override": false}, "shifts": {"name": "shifts", "group": "Ungrouped variables", "definition": "map(map(mod(x+j,26),x,cipher),j,1..26)", "description": "", "templateType": "anything", "can_override": false}, "translations": {"name": "translations", "group": "Ungrouped variables", "definition": "map(join(map(upper(letterordinal(x)),x,v),\"\"),v,shifts)", "description": "", "templateType": "anything", "can_override": false}, "plaintext": {"name": "plaintext", "group": "Ungrouped variables", "definition": "random([\"FORUM\",\"AGORA\",\"BATHS\",\"TIBER\",\"HOUSE\"])", "description": "", "templateType": "anything", "can_override": false}, "ciphertext": {"name": "ciphertext", "group": "Ungrouped variables", "definition": "join(map(upper(letterordinal(n)),n,cipher),\"\")", "description": "", "templateType": "anything", "can_override": false}, "advice": {"name": "advice", "group": "Ungrouped variables", "definition": "html(\"
    \"+join(map(\"
  1. k={k+1}: {v}
  2. \",[k,v],enumerate(translations)),\"\")+\"
\")", "description": "", "templateType": "anything", "can_override": false}}, "variablesTest": {"condition": "", "maxRuns": 100}, "ungrouped_variables": ["shift", "plaintext", "ciphertext", "cipher", "shifts", "translations", "advice"], "variable_groups": [], "functions": {"ordinalfromletter": {"parameters": [["word", "string"]], "type": "list", "language": "javascript", "definition": "var s = []\nfor (var c of word) {\n s.push(c.charCodeAt(0)-65)\n}\nreturn s"}}, "preamble": {"js": "", "css": ""}, "parts": [{"type": "patternmatch", "useCustomName": false, "customName": "", "marks": 1, "scripts": {}, "customMarkingAlgorithm": "", "extendBaseMarkingAlgorithm": true, "unitTests": [], "showCorrectAnswer": true, "showFeedbackIcon": true, "variableReplacements": [], "variableReplacementStrategy": "originalfirst", "nextParts": [], "suggestGoingBack": false, "adaptiveMarkingPenalty": 0, "exploreObjective": null, "answer": "{plaintext}", "displayAnswer": "{plaintext}", "matchMode": "exact"}], "partsMode": "all", "maxMarks": 0, "objectives": [], "penalties": [], "objectiveVisibility": "always", "penaltyVisibility": "always", "contributors": [{"name": "Julien Ugon", "profile_url": "https://numbas.mathcentre.ac.uk/accounts/profile/3575/"}, {"name": "Guillermo Pineda", "profile_url": "https://numbas.mathcentre.ac.uk/accounts/profile/20075/"}]}]}], "contributors": [{"name": "Julien Ugon", "profile_url": "https://numbas.mathcentre.ac.uk/accounts/profile/3575/"}, {"name": "Guillermo Pineda", "profile_url": "https://numbas.mathcentre.ac.uk/accounts/profile/20075/"}]}