// Numbas version: exam_results_page_options {"name": "Group theory", "metadata": {"description": "

Questions used in a university course titled \"Group theory\".

\n

The questions deal with permutations written in cycle or two-line notation.

", "licence": "Creative Commons Attribution 4.0 International"}, "duration": 0, "percentPass": 0, "showQuestionGroupNames": false, "showstudentname": true, "question_groups": [{"name": "Group", "pickingStrategy": "all-ordered", "pickQuestions": 1, "questionNames": ["", "", "", "", ""], "questions": [{"name": "Conjugate of permutations", "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}, "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/"}], "tags": ["permutations"], "metadata": {"description": "", "licence": "None specified"}, "statement": "", "advice": "

You could find $\\tau \\sigma \\tau^{-1}$ by first finding $\\tau^{-1}$ and then performing the composition by hand, but there's a quicker way: $\\tau \\sigma \\tau^{-1}$ has the same cycle structure as $\\sigma$, but each $n$ is replaced by $\\tau(n)$.

\n
Proof
\n

Assume, without loss of generality, that $\\sigma$ is a single cycle $(b_1, \\dots, b_n)$, and let $\\pi = \\tau \\sigma \\tau^{-1}$. Look at what happens to $\\tau(b_i)$ when acted on by $\\sigma$:

\n

\\[ \\tau(b_i) \\overset{\\tau^{-1}}\\mapsto b_i \\overset{\\sigma}\\mapsto b_{i+1} \\overset{\\tau}\\mapsto \\tau(b_{i+1}) \\]

\n

So, for any $1 \\lt i \\leq n$, $\\tau(b_i) \\overset{\\pi}\\mapsto \\tau(b_{i+1})$.

\n

For any $x \\notin \\{b_1,\\dots,b_n\\}$, $\\sigma(x) = x$, so $\\pi(x) = x$.

\n

Hence, $\\pi$ is the cycle $(\\tau(b_1), \\dots, \\tau(b_n))$.

\n

a)

\n

$\\var{conjugate1}$

\n

b)

\n

$\\var{conjugate2}$

\n", "rulesets": {}, "variables": {"sigma1": {"name": "sigma1", "group": "Ungrouped variables", "definition": "perm(randomcycle(7))", "description": "", "templateType": "anything"}, "conjugate1": {"name": "conjugate1", "group": "Ungrouped variables", "definition": "tau1*sigma1*inverse(tau1)", "description": "", "templateType": "anything"}, "tau1": {"name": "tau1", "group": "Ungrouped variables", "definition": "perm(deal(random(5..11)))", "description": "", "templateType": "anything"}, "tau2": {"name": "tau2", "group": "Ungrouped variables", "definition": "perm(deal(random(5..11)))", "description": "", "templateType": "anything"}, "conjugate2": {"name": "conjugate2", "group": "Ungrouped variables", "definition": "tau2*sigma2*inverse(tau2)", "description": "", "templateType": "anything"}, "sigma2": {"name": "sigma2", "group": "Ungrouped variables", "definition": "perm(deal(random(5..11)))", "description": "", "templateType": "anything"}}, "variablesTest": {"condition": "", "maxRuns": 100}, "ungrouped_variables": ["tau1", "tau2", "sigma1", "sigma2", "conjugate1", "conjugate2"], "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;"}, "sum": {"parameters": [["l", "list"]], "type": "number", "language": "javascript", "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;"}, "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;"}, "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;"}}, "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": "

Where $\\sigma = \\var{sigma1}$ and $\\tau = \\var{tau1}$, write down the permutation $\\tau \\sigma \\tau^{-1}$.

\n

$\\tau \\sigma \\tau^{-1}$ = [[0]]

", "gaps": [{"type": "write-a-permutation-in-cycle-notation", "useCustomName": false, "customName": "", "marks": 1, "scripts": {}, "customMarkingAlgorithm": "", "extendBaseMarkingAlgorithm": true, "unitTests": [], "showCorrectAnswer": true, "showFeedbackIcon": true, "variableReplacements": [], "variableReplacementStrategy": "originalfirst", "nextParts": [], "suggestGoingBack": false, "adaptiveMarkingPenalty": 0, "exploreObjective": null, "settings": {"correct_answer": "conjugate1", "must_be_disjoint": false, "must_be_transpositions": false}}], "sortAnswers": false}, {"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": "

Where $\\sigma = \\var{sigma2}$ and $\\tau = \\var{tau2}$, write down the permutation $\\tau \\sigma \\tau^{-1}$.

\n

$\\tau \\sigma \\tau^{-1}$ = [[0]]\n

", "gaps": [{"type": "write-a-permutation-in-cycle-notation", "useCustomName": false, "customName": "", "marks": 1, "scripts": {}, "customMarkingAlgorithm": "", "extendBaseMarkingAlgorithm": true, "unitTests": [], "showCorrectAnswer": true, "showFeedbackIcon": true, "variableReplacements": [], "variableReplacementStrategy": "originalfirst", "nextParts": [], "suggestGoingBack": false, "adaptiveMarkingPenalty": 0, "exploreObjective": null, "settings": {"correct_answer": "conjugate2", "must_be_disjoint": false, "must_be_transpositions": false}}], "sortAnswers": false}], "partsMode": "all", "maxMarks": 0, "objectives": [], "penalties": [], "objectiveVisibility": "always", "penaltyVisibility": "always"}, {"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}, "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/"}], "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": {}, "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"}, {"name": "Permutations: two-line form", "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}, "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/"}], "tags": ["permutations"], "metadata": {"description": "", "licence": "None specified"}, "statement": "

\\[ \\pi = \\var{twoline(ppi)} \\]

", "advice": "

Each number on the top row is mapped to the number directly beneath it. To find a disjoint cycle, pick a number and trace it through repeated applications of the permutation until you get back to the number you started with. Do this for each number to find every disjoint cycle.

\n

The order of the permutation $\\pi$ is the lowest common multiple of the orders of its disjoint cycles.

\n

1\">There are $\\var{ppi_num_cycles}$ nontrivial disjoint cycles, of lengths {showlist(ppi_cycle_lengths)}. The lowest common multiple of those numbers is $\\var{lcm(ppi_cycle_lengths)}$, so the order of $\\pi$ is $\\var{lcm(ppi_cycle_lengths)}$.

\n

There is one nontrivial disjoint cycle, of length $\\var{ppi_cycle_lengths[0]}$, so the order of $\\pi$ is $\\var{lcm(ppi_cycle_lengths)}$.

\n

A permutation is even if it can be written as the product of an even number of transpositions. This is true if and only if, when decomposed into a product of disjoint cycles, there are an even number of cycles of even length. $\\pi$ has $\\var{ppi_num_even_cycles}$ {pluralise(ppi_num_even_cycles,'cycle','cycles')} of even length, so is an {if(even(ppi),'even','odd')} permutation.

", "rulesets": {}, "variables": {"ppi_num_even_cycles": {"name": "ppi_num_even_cycles", "group": "Ungrouped variables", "definition": "sum(map(1-mod(x,2),x,ppi_cycle_lengths))", "description": "", "templateType": "anything"}, "ppi_cycle_lengths": {"name": "ppi_cycle_lengths", "group": "Ungrouped variables", "definition": "map(len(x),x,nontrivial_cycles(ppi))", "description": "", "templateType": "anything"}, "ppi": {"name": "ppi", "group": "Ungrouped variables", "definition": "perm(deal(random(6..11)))", "description": "", "templateType": "anything"}, "ppi_num_cycles": {"name": "ppi_num_cycles", "group": "Ungrouped variables", "definition": "len(nontrivial_cycles(ppi))", "description": "", "templateType": "anything"}}, "variablesTest": {"condition": "", "maxRuns": 100}, "ungrouped_variables": ["ppi_num_even_cycles", "ppi_num_cycles", "ppi", "ppi_cycle_lengths"], "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;"}, "sum": {"parameters": [["l", "list"]], "type": "number", "language": "javascript", "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;"}, "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;i1) {\n out += '^{'+factors[i]+'}';\n }\n }\n}\nreturn out;"}, "showsum": {"parameters": [["l", "list"]], "type": "string", "language": "javascript", "definition": "var t = 0;\nvar out = '';\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 $\\pi$ and $\\pi^{-1}$ as a product of disjoint cycles.

\n

$\\pi = $ [[0]]

\n

$\\pi^{-1} = $ [[1]]

", "gaps": [{"type": "write-a-permutation-in-cycle-notation", "useCustomName": true, "customName": "$\\pi$", "marks": 1, "scripts": {}, "customMarkingAlgorithm": "", "extendBaseMarkingAlgorithm": true, "unitTests": [{"variables": [{"name": "ppi_num_even_cycles", "value": "1"}, {"name": "ppi_num_cycles", "value": "1"}, {"name": "ppi", "value": "perm(\"(1,6,7,5,4,2)\")"}, {"name": "ppi_cycle_lengths", "value": "[ 6 ]"}], "answer": {"empty": false, "valid": true, "value": "(1,6,7,5,4,2)"}, "notes": [{"name": "mark", "expected": {"value": "nothing", "messages": ["Your answer is correct.\n\nYou were awarded 1 mark."], "warnings": [], "error": "", "valid": true, "credit": 1}}]}], "showCorrectAnswer": true, "showFeedbackIcon": true, "variableReplacements": [], "variableReplacementStrategy": "originalfirst", "nextParts": [], "suggestGoingBack": false, "adaptiveMarkingPenalty": 0, "exploreObjective": null, "settings": {"correct_answer": "ppi", "must_be_disjoint": true, "must_be_transpositions": false}}, {"type": "write-a-permutation-in-cycle-notation", "useCustomName": true, "customName": "$\\pi^{-1}$", "marks": 1, "scripts": {}, "customMarkingAlgorithm": "", "extendBaseMarkingAlgorithm": true, "unitTests": [], "showCorrectAnswer": true, "showFeedbackIcon": true, "variableReplacements": [], "variableReplacementStrategy": "originalfirst", "nextParts": [], "suggestGoingBack": false, "adaptiveMarkingPenalty": 0, "exploreObjective": null, "settings": {"correct_answer": "inverse(ppi)", "must_be_disjoint": true, "must_be_transpositions": false}}], "sortAnswers": false}, {"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": "

What is the order of $\\pi$? [[0]]

", "gaps": [{"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, "minValue": "order(ppi)", "maxValue": "order(ppi)", "correctAnswerFraction": false, "allowFractions": false, "mustBeReduced": false, "mustBeReducedPC": 0, "showFractionHint": true, "notationStyles": ["plain", "en", "si-en"], "correctAnswerStyle": "plain"}], "sortAnswers": false}, {"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": "

$\\pi$ is [[0]]

", "gaps": [{"type": "1_n_2", "useCustomName": false, "customName": "", "marks": 0, "scripts": {}, "customMarkingAlgorithm": "", "extendBaseMarkingAlgorithm": true, "unitTests": [], "showCorrectAnswer": true, "showFeedbackIcon": true, "variableReplacements": [], "variableReplacementStrategy": "originalfirst", "nextParts": [], "suggestGoingBack": false, "adaptiveMarkingPenalty": 0, "exploreObjective": null, "minMarks": 0, "maxMarks": 0, "shuffleChoices": false, "displayType": "radiogroup", "displayColumns": 0, "showCellAnswerState": true, "choices": ["

an even permutation

", "

an odd permutation

"], "matrix": "if(even(ppi),[1,0],[0,1])"}], "sortAnswers": false}], "partsMode": "all", "maxMarks": 0, "objectives": [], "penalties": [], "objectiveVisibility": "always", "penaltyVisibility": "always"}, {"name": "Write a permutation as a product of disjoint cycles", "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}, "contributors": [{"name": "Bill Foster", "profile_url": "https://numbas.mathcentre.ac.uk/accounts/profile/6/"}, {"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/"}], "tags": ["checked2015", "groups", "permutations"], "metadata": {"description": "", "licence": "None specified"}, "statement": "", "advice": "

Each set of brackets represents a cycle, with each number being mapped to the one on its right, and the last number in the sequence mapped to the first.

\n

Follow each number through the cycles, starting with the rightmost cycle and reading leftwards. For example, here's how $1$ is mapped to $\\var{prod[1]}$:

\n

\\[ \\var{latex(tracemap(1,perms))} \\]

\n

Then repeat this for $\\var{prod[1]}$, until you get back to $1$. This is a single cycle. If any number is not included in this cycle, repeat this process starting at that number to get another, disjoint, cycle. Some numbers are mapped to themselves - these are trivial cycles and you don't need to write them down. Once you've covered every number, you should have the following:

\n

\\[ \\var{prod} \\]

\n", "rulesets": {}, "variables": {"prod": {"name": "prod", "group": "Ungrouped variables", "definition": "compose(perms[0],perms[1],perms[2],perms[3])", "description": "", "templateType": "anything"}, "n": {"name": "n", "group": "Ungrouped variables", "definition": "random(4..9)", "description": "", "templateType": "anything"}, "perms": {"name": "perms", "group": "Ungrouped variables", "definition": "repeat(perm(randomcycle(n)),4)", "description": "", "templateType": "anything"}}, "variablesTest": {"condition": "", "maxRuns": 100}, "ungrouped_variables": ["perms", "prod", "n"], "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": "write-a-permutation-in-cycle-notation", "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": "

Write as a product of disjoint cycles

\n

\\[\\var{perms[0]} \\var{perms[1]} \\var{perms[2]} \\var{perms[3]} \\]

", "settings": {"correct_answer": "prod", "must_be_disjoint": true, "must_be_transpositions": false}}], "partsMode": "all", "maxMarks": 0, "objectives": [], "penalties": [], "objectiveVisibility": "always", "penaltyVisibility": "always"}, {"name": "Write a permutation as a product of transpositions", "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}, "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/"}], "tags": ["permutations"], "metadata": {"description": "", "licence": "None specified"}, "statement": "", "advice": "

a)

\n

\\[ \\var{as_transpositions(pi1)} \\]

\n

b)

\n

\\[ \\var{as_transpositions(pi2)} \\]

", "rulesets": {}, "variables": {"pi1": {"name": "pi1", "group": "Ungrouped variables", "definition": "perm(randomcycle(random(5..9)))", "description": "", "templateType": "anything"}, "pi2": {"name": "pi2", "group": "Ungrouped variables", "definition": "perm(deal(random(11..17)))", "description": "", "templateType": "anything"}}, "variablesTest": {"condition": "", "maxRuns": 100}, "ungrouped_variables": ["pi1", "pi2"], "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;"}, "sum": {"parameters": [["l", "list"]], "type": "number", "language": "javascript", "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;"}, "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;i1) {\n out += '^{'+factors[i]+'}';\n }\n }\n}\nreturn out;"}, "showsum": {"parameters": [["l", "list"]], "type": "string", "language": "javascript", "definition": "var t = 0;\nvar out = '';\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 the permutation $\\pi_1 = \\var{pi1}$ as a product of transpositions.

\n

$\\pi_1 = $ [[0]]\n

", "gaps": [{"type": "write-a-permutation-in-cycle-notation", "useCustomName": false, "customName": "", "marks": 1, "scripts": {}, "customMarkingAlgorithm": "", "extendBaseMarkingAlgorithm": true, "unitTests": [], "showCorrectAnswer": true, "showFeedbackIcon": true, "variableReplacements": [], "variableReplacementStrategy": "originalfirst", "nextParts": [], "suggestGoingBack": false, "adaptiveMarkingPenalty": 0, "exploreObjective": null, "settings": {"correct_answer": "pi1", "must_be_disjoint": false, "must_be_transpositions": true}}], "sortAnswers": false}, {"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 the permutation $\\pi_2 = \\var{pi2}$ as a product of transpositions.

\n

$\\pi_2 = $ [[0]]\n

", "gaps": [{"type": "write-a-permutation-in-cycle-notation", "useCustomName": false, "customName": "", "marks": 1, "scripts": {}, "customMarkingAlgorithm": "", "extendBaseMarkingAlgorithm": true, "unitTests": [], "showCorrectAnswer": true, "showFeedbackIcon": true, "variableReplacements": [], "variableReplacementStrategy": "originalfirst", "nextParts": [], "suggestGoingBack": false, "adaptiveMarkingPenalty": 0, "exploreObjective": null, "settings": {"correct_answer": "pi2", "must_be_disjoint": false, "must_be_transpositions": true}}], "sortAnswers": false}], "partsMode": "all", "maxMarks": 0, "objectives": [], "penalties": [], "objectiveVisibility": "always", "penaltyVisibility": "always"}]}], "navigation": {"allowregen": true, "reverse": true, "browse": true, "allowsteps": true, "showfrontpage": true, "showresultspage": "oncompletion", "navigatemode": "sequence", "onleave": {"action": "none", "message": ""}, "preventleave": true, "startpassword": ""}, "timing": {"allowPause": true, "timeout": {"action": "none", "message": ""}, "timedwarning": {"action": "none", "message": ""}}, "feedback": {"showactualmark": true, "showtotalmark": true, "showanswerstate": true, "allowrevealanswer": true, "advicethreshold": 0, "intro": "", "reviewshowscore": true, "reviewshowfeedback": true, "reviewshowexpectedanswer": true, "reviewshowadvice": true, "feedbackmessages": []}, "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/"}], "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": []}