// Numbas version: exam_results_page_options {"name": "Lois's copy of Write a permutation as a product of transpositions", "extensions": ["permutations"], "custom_part_types": [], "resources": [], "navigation": {"allowregen": true, "showfrontpage": false, "preventleave": false, "typeendtoleave": false}, "question_groups": [{"pickingStrategy": "all-ordered", "questions": [{"ungrouped_variables": ["pi1", "pi2"], "metadata": {"licence": "Creative Commons Attribution 4.0 International", "description": ""}, "advice": "
\nPossible solutions are shown below -- but remember that these are not unique.
\na) \\[ \\var{as_transpositions(pi1)} \\]
\n\nb) Recall that you can just write each cycle in turn as a product of transpositions. \\[ \\var{as_transpositions(pi2)} \\]
", "preamble": {"css": "", "js": ""}, "extensions": ["permutations"], "statement": "For this question you need to enter a transposition using commas between the terms in it. Do not leave spaces between each transposition in a product (composition).
", "tags": [], "rulesets": {}, "parts": [{"showCorrectAnswer": true, "marks": 0, "type": "gapfill", "gaps": [{"showCorrectAnswer": true, "marks": 1, "displayAnswer": "{as_transpositions(pi1)}", "type": "patternmatch", "answer": "", "variableReplacementStrategy": "originalfirst", "showFeedbackIcon": true, "variableReplacements": [], "matchMode": "regex", "scripts": {"validate": {"order": "instead", "script": "var Permutation = Numbas.extensions.permutations.Permutation;\ntry {\n Permutation.parse(this.studentAnswer);\n} catch(e) {\n this.giveWarning(\"Invalid notation\");\n return false;\n}\nreturn true;"}, "mark": {"order": "instead", "script": "this.setCredit(0);\nvar 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}\nif(!Permutation.is_transpositions(this.studentAnswer)) {\n this.setCredit(0,\"Your answer is not a product of transpositions\");\n return;\n}\nvar unwrapValue = Numbas.jme.unwrapValue;\nvar p_totranspose = unwrapValue(question.scope.variables.pi1);\nif(p.equal(p_totranspose)) {\n this.setCredit(1,\"Correct!\");\n} else {\n this.setCredit(0,\"Wrong\");\n}"}}}], "variableReplacementStrategy": "originalfirst", "showFeedbackIcon": true, "variableReplacements": [], "scripts": {}, "prompt": "Write the permutation $\\pi_1 = \\var{pi1}$ as a product (composition) of transpositions.
\n$\\pi_1 = $ [[0]]
"}, {"showCorrectAnswer": true, "marks": 0, "type": "gapfill", "gaps": [{"showCorrectAnswer": true, "marks": 1, "displayAnswer": "{as_transpositions(pi2)}", "type": "patternmatch", "answer": "", "variableReplacementStrategy": "originalfirst", "showFeedbackIcon": true, "variableReplacements": [], "matchMode": "regex", "scripts": {"validate": {"order": "instead", "script": "var Permutation = Numbas.extensions.permutations.Permutation;\ntry {\n Permutation.parse(this.studentAnswer);\n} catch(e) {\n this.giveWarning(\"Invalid notation\");\n return false;\n}\nreturn true;"}, "mark": {"order": "instead", "script": "this.setCredit(0);\nvar 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}\nif(!Permutation.is_transpositions(this.studentAnswer)) {\n this.setCredit(0,\"Your answer is not a product of transpositions\");\n return;\n}\nvar unwrapValue = Numbas.jme.unwrapValue;\nvar p_totranspose = unwrapValue(question.scope.variables.pi2);\nif(p.equal(p_totranspose)) {\n this.setCredit(1,\"Correct!\");\n} else {\n this.setCredit(0,\"Wrong\");\n}"}}}], "variableReplacementStrategy": "originalfirst", "showFeedbackIcon": true, "variableReplacements": [], "scripts": {}, "prompt": "Write the permutation $\\pi_2 = \\var{pi2}$ as a product (composition) of transpositions.
\n$\\pi_2 = $ [[0]]
"}], "functions": {"sum": {"language": "javascript", "type": "number", "parameters": [["l", "list"]], "definition": "var t = 0;\nfor(var i=0;i