// Numbas version: exam_results_page_options {"name": "Lois's copy of 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": [{"variable_groups": [], "preamble": {"css": "", "js": ""}, "ungrouped_variables": ["possible_orders", "candidate_possible", "candidate_orders", "other_orders", "possible_partitions", "s_order", "partition", "max_order", "s_n"], "rulesets": {}, "functions": {"tracemap": {"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;", "parameters": [["n", "number"], ["perms", "list"]], "type": "string"}, "randompartition": {"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;", "parameters": [["n", "number"]], "type": "list"}, "permfrompartition": {"language": "javascript", "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;", "parameters": [["l", "list"]], "type": "string"}, "showlist": {"language": "javascript", "definition": "var out = '';\nfor(var i=0;i1) {\n out += ' and ';\n } else if(i>0) {\n out += ', ';\n }\n out += '$'+l[i]+'$';\n}\nreturn out;", "parameters": [["l", "list"]], "type": "string"}, "show_factorisation": {"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;", "parameters": [["n", "number"]], "type": "string"}, "primepowerfactors": {"language": "javascript", "definition": "var factors = Numbas.math.factorise(n);\nvar out = [];\nfor(var i=0;i0) {\n var cycle_length = Math.pow(Numbas.math.primes[i],factors[i]);\n for(var j=0;jWrite down an element of $S_{\\var{s_n}}$ of order $\\var{s_order}$.

\n

Give your answer using cycle notation - include commas between the elements of a cycle and do not leave gaps between cycles. For instance you might enter(1, 2, 3)(4, 5).

\n

[[0]]

", "variableReplacements": [], "gaps": [{"matchMode": "regex", "answer": "", "variableReplacementStrategy": "originalfirst", "displayAnswer": "{show(perm(permwithorder(s_order)))}", "type": "patternmatch", "showCorrectAnswer": true, "marks": 1, "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}"}}, "variableReplacements": [], "showFeedbackIcon": true}], "showFeedbackIcon": true}], "advice": "

 

\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

", "name": "Lois's copy of Permutations of a given order", "statement": "", "extensions": ["permutations"], "variables": {"s_n": {"definition": "random(9..20)", "group": "Ungrouped variables", "name": "s_n", "templateType": "anything", "description": ""}, "max_order": {"definition": "floor(e^(s_n/e))", "group": "Ungrouped variables", "name": "max_order", "templateType": "anything", "description": ""}, "s_order": {"definition": "lcm(partition)", "group": "Ungrouped variables", "name": "s_order", "templateType": "anything", "description": ""}, "other_orders": {"definition": "map(x+1,x,deal(max_order)) except possible_orders", "group": "Ungrouped variables", "name": "other_orders", "templateType": "anything", "description": ""}, "candidate_possible": {"definition": "map(orderpossible(x,s_n),x,candidate_orders)", "group": "Ungrouped variables", "name": "candidate_possible", "templateType": "anything", "description": ""}, "possible_orders": {"definition": "map(lcm(x),x,possible_partitions) except s_order", "group": "Ungrouped variables", "name": "possible_orders", "templateType": "anything", "description": ""}, "possible_partitions": {"definition": "repeat(randompartition(s_n),3)", "group": "Ungrouped variables", "name": "possible_partitions", "templateType": "anything", "description": ""}, "partition": {"definition": "randompartition(s_n)", "group": "Ungrouped variables", "name": "partition", "templateType": "anything", "description": ""}, "candidate_orders": {"definition": "distinct(possible_orders+other_orders)[0..6]", "group": "Ungrouped variables", "name": "candidate_orders", "templateType": "anything", "description": ""}}, "metadata": {"licence": "Creative Commons Attribution 4.0 International", "description": ""}, "tags": [], "type": "question", "contributors": [{"name": "Lois Rollings", "profile_url": "https://numbas.mathcentre.ac.uk/accounts/profile/326/"}]}]}], "contributors": [{"name": "Lois Rollings", "profile_url": "https://numbas.mathcentre.ac.uk/accounts/profile/326/"}]}