// Numbas version: exam_results_page_options {"name": "Permutations of a given order", "extensions": ["permutations"], "custom_part_types": [{"source": {"pk": 68, "author": {"name": "Christian Lawson-Perfect", "pk": 7}, "edit_page": "/part_type/68/edit"}, "name": "Write a permutation in cycle notation", "short_name": "write-a-permutation-in-cycle-notation", "description": "

The student must write a permutation in cycle notation. You can optionally require the cycles to be disjoint and/or all of length 2.

", "help_url": "", "input_widget": "string", "input_options": {"correctAnswer": "let(ans,\n if(settings[\"must_be_transpositions\"],\n as_transpositions(settings[\"correct_answer\"]),\n show(settings[\"correct_answer\"])\n ),\n if(ans=\"\",settings[\"identity_name\"],ans)\n)", "hint": {"static": false, "value": "if(settings[\"show_hint\"],\n if(settings[\"must_be_disjoint\"],\n if(settings[\"must_be_transpositions\"],\n \"Write a permutation in cycle notation as a product of disjoint transpositions.\",\n \"Write a permutation in cycle notation as a product of disjoint cycles.\"\n ),\n if(settings[\"must_be_transpositions\"],\n \"Write a permutation in cycle notation as a product of transpositions.\",\n \"Write a permutation in cycle notation.\"\n )\n ),\n \"\"\n)"}, "allowEmpty": {"static": true, "value": false}}, "can_be_gap": true, "can_be_step": true, "marking_script": "mark:\napply(student_permutation);\napply(is_correct);\napply(is_disjoint);\napply(is_transpositions)\n\ninterpreted_answer:\nstudent_permutation\n\nis_correct:\ncorrectif(student_permutation=settings[\"correct_answer\"])\n\nis_disjoint:\nif(is_disjoint(studentAnswer),\n true\n,\n assert(not settings[\"must_be_disjoint\"],\n set_credit(0,\"You have not written your answer as a product of disjoint cycles.\"),\n );\n false\n)\n\nstudent_permutation:\ntry(\n if(studentAnswer=settings[\"identity_name\"],\n permutation(\"\"), \n permutation(studentAnswer)\n ),\n message,\n warn(\"Your answer is not valid cycle notation: \"+message);\n fail(\"Your answer is not valid cycle notation: \"+message)\n)\n\nis_transpositions:\nif(is_transpositions(studentAnswer),\n true\n,\n assert(not settings[\"must_be_transpositions\"],\n set_credit(0,\"You have not written your answer as a product of transpositions.\")\n );\n false\n)", "marking_notes": [{"name": "mark", "description": "This is the main marking note. It should award credit and provide feedback based on the student's answer.", "definition": "apply(student_permutation);\napply(is_correct);\napply(is_disjoint);\napply(is_transpositions)"}, {"name": "interpreted_answer", "description": "A value representing the student's answer to this part.", "definition": "student_permutation"}, {"name": "is_correct", "description": "", "definition": "correctif(student_permutation=settings[\"correct_answer\"])"}, {"name": "is_disjoint", "description": "", "definition": "if(is_disjoint(studentAnswer),\n true\n,\n assert(not settings[\"must_be_disjoint\"],\n set_credit(0,\"You have not written your answer as a product of disjoint cycles.\"),\n );\n false\n)"}, {"name": "student_permutation", "description": "", "definition": "try(\n if(studentAnswer=settings[\"identity_name\"],\n permutation(\"\"), \n permutation(studentAnswer)\n ),\n message,\n warn(\"Your answer is not valid cycle notation: \"+message);\n fail(\"Your answer is not valid cycle notation: \"+message)\n)"}, {"name": "is_transpositions", "description": "", "definition": "if(is_transpositions(studentAnswer),\n true\n,\n assert(not settings[\"must_be_transpositions\"],\n set_credit(0,\"You have not written your answer as a product of transpositions.\")\n );\n false\n)"}], "settings": [{"name": "correct_answer", "label": "Correct answer", "help_url": "", "hint": "", "input_type": "code", "default_value": "", "evaluate": true}, {"name": "show_hint", "label": "Show answer input hint?", "help_url": "", "hint": "", "input_type": "checkbox", "default_value": true}, {"name": "must_be_disjoint", "label": "Must the cycles be disjoint?", "help_url": "", "hint": "", "input_type": "checkbox", "default_value": false}, {"name": "must_be_transpositions", "label": "Must the cycles be transpositions?", "help_url": "", "hint": "", "input_type": "checkbox", "default_value": false}, {"name": "identity_name", "label": "Name of the identity permutation", "help_url": "", "hint": "The student should write this string for the identity permutation.", "input_type": "string", "default_value": "e", "subvars": true}], "public_availability": "always", "published": true, "extensions": ["permutations"]}], "resources": [], "navigation": {"allowregen": true, "showfrontpage": false, "preventleave": false, "typeendtoleave": false}, "question_groups": [{"pickingStrategy": "all-ordered", "questions": [{"name": "Permutations of a given order", "tags": ["permutations"], "metadata": {"description": "", "licence": "None specified"}, "statement": "", "advice": "

\n a)\n

\n

Note that $\\var{s_order} = \\var{latex(show_factorisation(s_order))}$. The order of a permutation is the lowest common multiple of the lengths of its disjoint cycles, so it suffices to write a permutation with {pluralise(len(factorise(s_order)),'a cycle of length','cycles of lengths')} {showlist(primepowerfactors(s_order))}.

\n

One such permutation is $\\var{permutation(permwithorder(s_order))}$.

\n

b)

\n

There exists an element of $S_\\var{s_n}$ of order $x$ if there exist integers $(a_1,\\dots,a_n)$ whose lowest common multiple is $x$ and whose sum is less than or equal to $\\var{s_n}$. You can establish whether this is the case by looking at the prime factorisation of $x$ - the LCM of the prime power factors of $x$ is $x$, so you just need to check that they sum to at most $\\var{s_n}$.

\n", "rulesets": {}, "extensions": ["permutations"], "variables": {"example_element": {"name": "example_element", "group": "Ungrouped variables", "definition": "let(\n p,perm(permwithorder(s_order)),\n d,s_n-size(p),\n perm(map(\n if(j<=d,j,d+p[j-d])-1,j,1..s_n))\n)", "description": "", "templateType": "anything"}, "candidate_possible": {"name": "candidate_possible", "group": "Ungrouped variables", "definition": "map(orderpossible(x,s_n),x,candidate_orders)", "description": "", "templateType": "anything"}, "max_order": {"name": "max_order", "group": "Ungrouped variables", "definition": "floor(e^(s_n/e))", "description": "", "templateType": "anything"}, "s_order": {"name": "s_order", "group": "Ungrouped variables", "definition": "lcm(partition)", "description": "", "templateType": "anything"}, "candidate_orders": {"name": "candidate_orders", "group": "Ungrouped variables", "definition": "distinct(possible_orders+other_orders)[0..6]", "description": "", "templateType": "anything"}, "s_n": {"name": "s_n", "group": "Ungrouped variables", "definition": "random(9..20)", "description": "", "templateType": "anything"}, "possible_orders": {"name": "possible_orders", "group": "Ungrouped variables", "definition": "map(lcm(x),x,possible_partitions) except s_order", "description": "", "templateType": "anything"}, "possible_partitions": {"name": "possible_partitions", "group": "Ungrouped variables", "definition": "repeat(randompartition(s_n),3)", "description": "", "templateType": "anything"}, "partition": {"name": "partition", "group": "Ungrouped variables", "definition": "randompartition(s_n)", "description": "", "templateType": "anything"}, "other_orders": {"name": "other_orders", "group": "Ungrouped variables", "definition": "map(x+1,x,deal(max_order)) except possible_orders", "description": "", "templateType": "anything"}}, "variablesTest": {"condition": "", "maxRuns": "100"}, "ungrouped_variables": ["possible_orders", "possible_partitions", "partition", "candidate_possible", "other_orders", "s_order", "candidate_orders", "max_order", "s_n", "example_element"], "variable_groups": [], "functions": {"randompartition": {"parameters": [["n", "number"]], "type": "list", "language": "javascript", "definition": "var l = [];\nwhile(n) {\n var t = Numbas.math.randomint(n)+1;\n l.push(t);\n n -= t;\n}\nreturn l;"}, "tracemap": {"parameters": [["n", "number"], ["perms", "list"]], "type": "string", "language": "javascript", "definition": "n -= 1;\nvar l = perms.length;\nvar out = ''+(n+1);\nfor(var i=l-1;i>=0;i--) {\n n = perms[i].map(n);\n out += ' \\\\to '+(n+1);\n}\nreturn out;"}, "show_factorisation": {"parameters": [["n", "number"]], "type": "string", "language": "javascript", "definition": "var factors = Numbas.math.factorise(n);\nvar out = '';\nfor(var i=0;i1) {\n out += '^{'+factors[i]+'}';\n }\n }\n}\nreturn out;"}, "permfrompartition": {"parameters": [["cycle_sizes", "list"]], "type": "list", "language": "javascript", "definition": "var to = [];\nvar offset = 0;\nfor(var i=0; i0) {\n var cycle_length = Math.pow(Numbas.math.primes[i],factors[i]);\n for(var j=0;j1) {\n out += ' and ';\n } else if(i>0) {\n out += ', ';\n }\n out += '$'+l[i]+'$';\n}\nreturn out;"}, "orderpossible": {"parameters": [["n", "number"], ["s_n", "number"]], "type": "boolean", "language": "javascript", "definition": "var factors = Numbas.math.factorise(n);\nvar t = 0;\nfor(var i=0;i0) {\n out += ' + ';\n }\n out += l[i]\n t += l[i];\n}\nout += ' = '+t;\nreturn out;"}}, "preamble": {"js": "", "css": ""}, "parts": [{"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": "

Write down an element of $S_{\\var{s_n}}$ of order $\\var{s_order}$.

\n

[[0]]

", "gaps": [{"type": "write-a-permutation-in-cycle-notation", "useCustomName": false, "customName": "", "marks": 1, "scripts": {}, "customMarkingAlgorithm": "student_size: size(student_permutation)\n\nstudent_order: order(student_permutation)\n\nis_right_size:\n assert(student_size=s_n,\n incorrect(\"Your permutation belongs to $S_{\"+student_size+\"}$, not $S_{\"+s_n+\"}$.\");\n end()\n )\n\nhas_right_order:\n assert(student_order=s_order,\n incorrect(\"Your permutation is an element of $S_{\"+s_n+\"}$ but it has order \"+student_order+\", not \"+s_order);\n end()\n )\n\nmark:\n apply(student_permutation);\n apply(is_right_size);\n apply(has_right_order);\n correct()", "extendBaseMarkingAlgorithm": true, "unitTests": [], "showCorrectAnswer": true, "showFeedbackIcon": true, "variableReplacements": [], "variableReplacementStrategy": "originalfirst", "nextParts": [], "suggestGoingBack": false, "adaptiveMarkingPenalty": 0, "exploreObjective": null, "settings": {"correct_answer": "example_element", "must_be_disjoint": false, "must_be_transpositions": false}}], "sortAnswers": false}, {"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": "

Which of the following are possible orders of elements of $S_{\\var{s_n}}$?

", "minMarks": "0", "maxMarks": "0", "minAnswers": "0", "maxAnswers": "0", "shuffleChoices": false, "shuffleAnswers": false, "displayType": "radiogroup", "warningType": "none", "showCellAnswerState": true, "choices": ["$\\var{candidate_orders[0]}$", "$\\var{candidate_orders[1]}$", "$\\var{candidate_orders[2]}$", "$\\var{candidate_orders[3]}$", "$\\var{candidate_orders[4]}$", "$\\var{candidate_orders[5]}$"], "matrix": "let(mark,1/2, map(if(orderpossible(x,s_n),[mark,-mark],[-mark,mark]),x,candidate_orders))", "layout": {"type": "all", "expression": ""}, "answers": ["Possible", "Not possible"]}], "partsMode": "all", "maxMarks": 0, "objectives": [], "penalties": [], "objectiveVisibility": "always", "penaltyVisibility": "always", "contributors": [{"name": "Christian Lawson-Perfect", "profile_url": "https://numbas.mathcentre.ac.uk/accounts/profile/7/"}, {"name": "Newcastle University Mathematics and Statistics", "profile_url": "https://numbas.mathcentre.ac.uk/accounts/profile/697/"}]}]}], "contributors": [{"name": "Christian Lawson-Perfect", "profile_url": "https://numbas.mathcentre.ac.uk/accounts/profile/7/"}, {"name": "Newcastle University Mathematics and Statistics", "profile_url": "https://numbas.mathcentre.ac.uk/accounts/profile/697/"}]}