// Numbas version: exam_results_page_options {"name": "Permutations of a given order", "extensions": ["permutations"], "custom_part_types": [], "resources": [], "navigation": {"allowregen": true, "showfrontpage": false, "preventleave": false, "typeendtoleave": false}, "question_groups": [{"pickingStrategy": "all-ordered", "questions": [{"functions": {"orderpossible": {"definition": "var factors = Numbas.math.factorise(n);\nvar t = 0;\nfor(var i=0;i1) {\n out += '^{'+factors[i]+'}';\n }\n }\n}\nreturn out;", "type": "string", "language": "javascript", "parameters": [["n", "number"]]}, "sum": {"definition": "var t = 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;", "type": "string", "language": "javascript", "parameters": [["l", "list"]]}, "permfrompartition": {"definition": "var to = [];\nvar offset = 0;\nfor(var i=0; i0) {\n out += ' + ';\n }\n out += l[i]\n t += l[i];\n}\nout += ' = '+t;\nreturn out;", "type": "string", "language": "javascript", "parameters": [["l", "list"]]}, "randompartition": {"definition": "var l = [];\nwhile(n) {\n var t = Numbas.math.randomint(n)+1;\n l.push(t);\n n -= t;\n}\nreturn l;", "type": "list", "language": "javascript", "parameters": [["n", "number"]]}, "tracemap": {"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;", "type": "string", "language": "javascript", "parameters": [["n", "number"], ["perms", "list"]]}}, "name": "Permutations of a given order", "tags": ["permutations"], "type": "question", "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": {}, "parts": [{"prompt": "

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

\n

[[0]]

", "marks": 0, "gaps": [{"marks": 1, "showCorrectAnswer": true, "displayAnswer": "{show(perm(permwithorder(s_order)))}", "scripts": {"validate": {"order": "instead", "script": "var Permutation = Numbas.extensions.permutations.Permutation;\ntry{\n Permutation.parse(this.studentAnswer);\n} catch(e) {\n return false;\n}\nreturn true;"}, "mark": {"order": "instead", "script": "var Permutation = Numbas.extensions.permutations.Permutation;\ntry {\n var p = Permutation.fromString(this.studentAnswer);\n} catch(e) {\n this.setCredit(0,\"Invalid notation\");\n return;\n}\nvar s_n = Numbas.jme.unwrapValue(question.scope.variables.s_n);\nif(p.n>s_n) {\n this.setCredit(0,\"Your permutation belongs to $S_{\"+p.n+\"}$, not $S_{\"+s_n+\"}$.\");\n return;\n}\nvar s_order = Numbas.jme.unwrapValue(question.scope.variables.s_order);\nif(p.order()==s_order) {\n this.setCredit(1,\"Correct.\");\n} else {\n this.setCredit(0,\"Your permutation is an element of $S_{\"+s_n+\"}$ but it has order \"+p.order()+\", not \"+s_order);\n}"}}, "answer": "", "type": "patternmatch"}], "showCorrectAnswer": true, "scripts": {}, "type": "gapfill"}, {"maxAnswers": 0, "prompt": "

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

", "matrix": "map(if(orderpossible(x,s_n),[1,0],[0,1]),x,candidate_orders)", "shuffleAnswers": false, "minAnswers": 0, "marks": 0, "answers": ["Possible", "Not possible"], "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]}$"], "displayType": "radiogroup", "showCorrectAnswer": true, "scripts": {}, "maxMarks": 0, "type": "m_n_x", "shuffleChoices": false, "minMarks": 0}], "statement": "", "variable_groups": [], "progress": "in-progress", "preamble": {"css": "", "js": ""}, "variables": {"possible_orders": {"definition": "map(lcm(x),x,possible_partitions) except s_order", "templateType": "anything", "group": "Ungrouped variables", "name": "possible_orders", "description": ""}, "possible_partitions": {"definition": "repeat(randompartition(s_n),3)", "templateType": "anything", "group": "Ungrouped variables", "name": "possible_partitions", "description": ""}, "partition": {"definition": "randompartition(s_n)", "templateType": "anything", "group": "Ungrouped variables", "name": "partition", "description": ""}, "candidate_possible": {"definition": "map(orderpossible(x,s_n),x,candidate_orders)", "templateType": "anything", "group": "Ungrouped variables", "name": "candidate_possible", "description": ""}, "other_orders": {"definition": "map(x+1,x,deal(max_order)) except possible_orders", "templateType": "anything", "group": "Ungrouped variables", "name": "other_orders", "description": ""}, "s_order": {"definition": "lcm(partition)", "templateType": "anything", "group": "Ungrouped variables", "name": "s_order", "description": ""}, "candidate_orders": {"definition": "distinct(possible_orders+other_orders)[0..6]", "templateType": "anything", "group": "Ungrouped variables", "name": "candidate_orders", "description": ""}, "max_order": {"definition": "floor(e^(s_n/e))", "templateType": "anything", "group": "Ungrouped variables", "name": "max_order", "description": ""}, "s_n": {"definition": "random(9..20)", "templateType": "anything", "group": "Ungrouped variables", "name": "s_n", "description": ""}}, "metadata": {"notes": "", "description": "", "licence": "Creative Commons Attribution 4.0 International"}, "showQuestionGroupNames": false, "question_groups": [{"name": "", "pickingStrategy": "all-ordered", "pickQuestions": 0, "questions": []}], "contributors": [{"name": "Christian Lawson-Perfect", "profile_url": "https://numbas.mathcentre.ac.uk/accounts/profile/7/"}]}]}], "contributors": [{"name": "Christian Lawson-Perfect", "profile_url": "https://numbas.mathcentre.ac.uk/accounts/profile/7/"}]}