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

These are some questions on graph theory, pulled from a module on groups and graphs.

", "licence": "Creative Commons Attribution 4.0 International"}, "duration": 0, "percentPass": 0, "showQuestionGroupNames": false, "shuffleQuestionGroups": false, "showstudentname": true, "question_groups": [{"name": "Group", "pickingStrategy": "all-ordered", "pickQuestions": 1, "questionNames": ["", "Match adjacency matrix to a graph", "Write the adjacency matrix of this graph", ""], "variable_overrides": [[], [], [], []], "questions": [{"name": "Are these graphs isomorphic?", "extensions": ["graph-theory", "permutations"], "custom_part_types": [{"source": {"pk": 2, "author": {"name": "Christian Lawson-Perfect", "pk": 7}, "edit_page": "/part_type/2/edit"}, "name": "List of numbers", "short_name": "list-of-numbers", "description": "

The answer is a comma-separated list of numbers.

\n

The list is marked correct if each number occurs the same number of times as in the expected answer, and no extra numbers are present.

\n

You can optionally treat the answer as a set, so the number of occurrences doesn't matter, only whether each number is included or not.

", "help_url": "", "input_widget": "string", "input_options": {"correctAnswer": "join(\n if(settings[\"correctAnswerFractions\"],\n map(let([a,b],rational_approximation(x), string(a/b)),x,settings[\"correctAnswer\"])\n ,\n settings[\"correctAnswer\"]\n ),\n settings[\"separator\"] + \" \"\n)", "hint": {"static": false, "value": "if(settings[\"show_input_hint\"],\n \"Enter a list of numbers separated by {settings['separator']}.\",\n \"\"\n)"}, "allowEmpty": {"static": true, "value": true}}, "can_be_gap": true, "can_be_step": true, "marking_script": "bits:\nlet(b,filter(x<>\"\",x,split(studentAnswer,settings[\"separator\"])),\n if(isSet,list(set(b)),b)\n)\n\nexpected_numbers:\nlet(l,settings[\"correctAnswer\"] as \"list\",\n if(isSet,list(set(l)),l)\n)\n\nvalid_numbers:\nif(all(map(not isnan(x),x,interpreted_answer)),\n true,\n let(index,filter(isnan(interpreted_answer[x]),x,0..len(interpreted_answer)-1)[0], wrong, bits[index],\n warn(wrong+\" is not a valid number\");\n fail(wrong+\" is not a valid number.\")\n )\n )\n\nis_sorted:\nassert(sort(interpreted_answer)=interpreted_answer,\n multiply_credit(0.5,\"Not in order\")\n )\n\nincluded:\nmap(\n let(\n num_student,len(filter(x=y,y,interpreted_answer)),\n num_expected,len(filter(x=y,y,expected_numbers)),\n switch(\n num_student=num_expected,\n true,\n num_studentThe separate items in the student's answer

", "definition": "let(b,filter(x<>\"\",x,split(studentAnswer,settings[\"separator\"])),\n if(isSet,list(set(b)),b)\n)"}, {"name": "expected_numbers", "description": "", "definition": "let(l,settings[\"correctAnswer\"] as \"list\",\n if(isSet,list(set(l)),l)\n)"}, {"name": "valid_numbers", "description": "

Is every number in the student's list valid?

", "definition": "if(all(map(not isnan(x),x,interpreted_answer)),\n true,\n let(index,filter(isnan(interpreted_answer[x]),x,0..len(interpreted_answer)-1)[0], wrong, bits[index],\n warn(wrong+\" is not a valid number\");\n fail(wrong+\" is not a valid number.\")\n )\n )"}, {"name": "is_sorted", "description": "

Are the student's answers in ascending order?

", "definition": "assert(sort(interpreted_answer)=interpreted_answer,\n multiply_credit(0.5,\"Not in order\")\n )"}, {"name": "included", "description": "

Is each number in the expected answer present in the student's list the correct number of times?

", "definition": "map(\n let(\n num_student,len(filter(x=y,y,interpreted_answer)),\n num_expected,len(filter(x=y,y,expected_numbers)),\n switch(\n num_student=num_expected,\n true,\n num_studentHas every number been included the right number of times?

", "definition": "all(included)"}, {"name": "no_extras", "description": "

True if the student's list doesn't contain any numbers that aren't in the expected answer.

", "definition": "if(all(map(x in expected_numbers, x, interpreted_answer)),\n true\n ,\n incorrect(\"Your answer contains \"+extra_numbers[0]+\" but should not.\");\n false\n )"}, {"name": "interpreted_answer", "description": "A value representing the student's answer to this part.", "definition": "if(lower(studentAnswer) in [\"empty\",\"\u2205\"],[],\n map(\n if(settings[\"allowFractions\"],parsenumber_or_fraction(x,notationStyles), parsenumber(x,notationStyles))\n ,x\n ,bits\n )\n)"}, {"name": "mark", "description": "This is the main marking note. It should award credit and provide feedback based on the student's answer.", "definition": "if(studentanswer=\"\",fail(\"You have not entered an answer\"),false);\napply(valid_numbers);\napply(included);\napply(no_extras);\ncorrectif(all_included and no_extras)"}, {"name": "notationStyles", "description": "", "definition": "[\"en\"]"}, {"name": "isSet", "description": "

Should the answer be considered as a set, so the number of times an element occurs doesn't matter?

", "definition": "settings[\"isSet\"]"}, {"name": "extra_numbers", "description": "

Numbers included in the student's answer that are not in the expected list.

", "definition": "filter(not (x in expected_numbers),x,interpreted_answer)"}], "settings": [{"name": "correctAnswer", "label": "Correct answer", "help_url": "", "hint": "The list of numbers that the student should enter. The order does not matter.", "input_type": "code", "default_value": "", "evaluate": true}, {"name": "allowFractions", "label": "Allow the student to enter fractions?", "help_url": "", "hint": "", "input_type": "checkbox", "default_value": false}, {"name": "correctAnswerFractions", "label": "Display the correct answers as fractions?", "help_url": "", "hint": "", "input_type": "checkbox", "default_value": false}, {"name": "isSet", "label": "Is the answer a set?", "help_url": "", "hint": "If ticked, the number of times an element occurs doesn't matter, only whether it's included at all.", "input_type": "checkbox", "default_value": false}, {"name": "show_input_hint", "label": "Show the input hint?", "help_url": "", "hint": "", "input_type": "checkbox", "default_value": true}, {"name": "separator", "label": "Separator", "help_url": "", "hint": "The substring that should separate items in the student's list", "input_type": "string", "default_value": ",", "subvars": false}], "public_availability": "always", "published": true, "extensions": []}, {"source": {"pk": 197, "author": {"name": "Christian Lawson-Perfect", "pk": 7}, "edit_page": "/part_type/197/edit"}, "name": "Write a permutation in two-line form", "short_name": "write-a-permutation-in-two-line-form", "description": "

The student must write out a permutation (an element of $S_n$) in two-line form: the top line always contains the numbers 1 to $n$, and on the bottom line they must write the numbers that they are mapped to.

", "help_url": "", "input_widget": "matrix", "input_options": {"correctAnswer": "matrix(map(settings[\"correctAnswer\"][i],i,1..settings[\"size\"]))", "hint": {"static": true, "value": ""}, "allowResize": {"static": true, "value": false}, "numRows": {"static": true, "value": 1}, "numColumns": {"static": false, "value": "settings[\"size\"]"}, "parseCells": {"static": true, "value": true}, "allowedNotationStyles": {"static": true, "value": ["plain"]}, "allowFractions": {"static": true, "value": false}, "showBrackets": {"static": true, "value": true}, "rowHeaders": {"static": false, "value": "[]"}, "columnHeaders": {"static": false, "value": "map(string(n),n,1..settings[\"size\"])"}}, "can_be_gap": true, "can_be_step": true, "marking_script": "mark:\napply(valid_permutation);\ncorrectif(student_permutation=settings[\"correctAnswer\"])\n\nstudent_numbers:\nlist(studentAnswer[0])\n\nstudent_permutation:\npermutation(map(x-1,x,student_numbers))\n\nvalid_permutation:\n assert(all(map(isint(x) and x>=1 and x<=settings[\"size\"], x, student_numbers)),\n fail(\"Your answer is not a valid permutation: each entry must be one of the numbers 1 \u2026 {settings['size']}.\")\n );\n assert(len(set(student_numbers))=settings[\"size\"],\n fail(\"Your answer is not a valid permutation: some entries occur more than once.\")\n )\n\ninterpreted_answer:\nstudent_permutation", "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(valid_permutation);\ncorrectif(student_permutation=settings[\"correctAnswer\"])"}, {"name": "student_numbers", "description": "

The numbers that the student typed.

", "definition": "list(studentAnswer[0])"}, {"name": "student_permutation", "description": "", "definition": "permutation(map(x-1,x,student_numbers))"}, {"name": "valid_permutation", "description": "", "definition": " assert(all(map(isint(x) and x>=1 and x<=settings[\"size\"], x, student_numbers)),\n fail(\"Your answer is not a valid permutation: each entry must be one of the numbers 1 \u2026 {settings['size']}.\")\n );\n assert(len(set(student_numbers))=settings[\"size\"],\n fail(\"Your answer is not a valid permutation: some entries occur more than once.\")\n )"}, {"name": "interpreted_answer", "description": "A value representing the student's answer to this part.", "definition": "student_permutation"}], "settings": [{"name": "correctAnswer", "label": "Correct answer", "help_url": "", "hint": "", "input_type": "code", "default_value": "", "evaluate": true}, {"name": "size", "label": "Size", "help_url": "", "hint": "", "input_type": "code", "default_value": "", "evaluate": true}], "public_availability": "always", "published": true, "extensions": []}, {"source": {"pk": 1, "author": {"name": "Christian Lawson-Perfect", "pk": 7}, "edit_page": "/part_type/1/edit"}, "name": "Yes/no", "short_name": "yes-no", "description": "

The student is shown two radio choices: \"Yes\" and \"No\". One of them is correct.

", "help_url": "", "input_widget": "radios", "input_options": {"correctAnswer": "if(eval(settings[\"correct_answer_expr\"]), 0, 1)", "hint": {"static": true, "value": ""}, "choices": {"static": true, "value": ["Yes", "No"]}}, "can_be_gap": true, "can_be_step": true, "marking_script": "mark:\nif(studentanswer=correct_answer,\n correct(),\n incorrect()\n)\n\ninterpreted_answer:\nstudentAnswer=0\n\ncorrect_answer:\nif(eval(settings[\"correct_answer_expr\"]),0,1)", "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": "if(studentanswer=correct_answer,\n correct(),\n incorrect()\n)"}, {"name": "interpreted_answer", "description": "A value representing the student's answer to this part.", "definition": "studentAnswer=0"}, {"name": "correct_answer", "description": "", "definition": "if(eval(settings[\"correct_answer_expr\"]),0,1)"}], "settings": [{"name": "correct_answer_expr", "label": "Is the answer \"Yes\"?", "help_url": "", "hint": "An expression which evaluates to true or false.", "input_type": "mathematical_expression", "default_value": "true", "subvars": false}], "public_availability": "always", "published": true, "extensions": []}], "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": "Sam Mutter", "profile_url": "https://numbas.mathcentre.ac.uk/accounts/profile/9360/"}], "tags": [], "metadata": {"description": "

The student is shown two labelled graphs. They are asked:

\n\n

The number of vertices is always equal, so this is a gimme.

\n

If the edges or degree sequences are different, the student is expected to realise that there cannot be an isomorphism.

\n

If these values are the same, then there will be an isomorphism (else the question is a bit too tricky).

\n

Numbas expects a particular isomorphism, but there may be more than one, all of which would be accepted.

", "licence": "Creative Commons Attribution 4.0 International"}, "statement": "

Consider the following labelled graphs, and their adjacency matrices:

\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n
$\\Gamma_1$$\\Gamma_2$
{draw(g1)}{draw(g2)}
$\\var{adjacency_matrix(g1)}$$\\var{adjacency_matrix(g2)}$
\n

", "advice": "

The vertices are the labelled \"dots\". In each graph there are {n+1} vertices.

\n

The edges are the lines connecting vertices. In $\\Gamma_1$ there are {len(edges(g1))} edges, and in $\\Gamma_2$ there are {len(edges(g2))}.

\n

The degree of a vertex is the number of edges incident to it.

\n

The degree sequence is a list of the degrees of all of the vertices of a graph, usually ordered from smallest to largest. The degree sequence of $\\Gamma_1$ is {join(sort(vertex_degrees(g1)),\", \")}.

\n

Similarly, the degree sequence of $\\Gamma_2$ is {join(sort(vertex_degrees(g2)),\", \")}. This is because, for example, {len(filter(i=2, i, vertex_degrees(g2)))} of the vertices in $\\Gamma_2$ have degree 2, {len(filter(i=3, i, vertex_degrees(g2)))} of the vertices in $\\Gamma_2$ have degree 3, and so on.

\n

Two graphs $\\Gamma_1, \\Gamma_2$ are isomorphic if there is a bijection from the vertex set of $\\Gamma_1$ to the vertex set of $\\Gamma_2$ that maps a pair of vertices joined by an edge to a pair of vertices joined by an edge, and that maps a pair of vertices not joined by an edge to a pair of vertices not joined by an edge. If there is no such bijection then the graphs are not isomorphic.

\n

There cannot be a graph isomorphism between two graphs if they have different numbers of vertices, different numbers of edges, or different degree sequences.

\n

{advice}

", "rulesets": {}, "builtin_constants": {"e": true, "pi,\u03c0": true, "i": true}, "constants": [], "variables": {"g1": {"name": "g1", "group": "Ungrouped variables", "definition": "set_vertex_labels( graph(map(edge(from,to),[from,to],\n [[0,1],[0,2]+[0,n-2],[0,n-1]]+\n flatten(map(map([j,k],k,shuffle(j+1..n-1)[0..random(1,2)]),j,1..n-1))\n)), map(string(x),x,1..n))", "description": "

The graph $\\Gamma_1$.

\n

Vertex 1 will be adjacent to four others.

\n

The remaining vertices will each be adjacent to either one or two later vertices.

\n

In this way, no vertex will be adjacent to more than four others.

", "templateType": "anything", "can_override": false}, "n": {"name": "n", "group": "Ungrouped variables", "definition": "random(6..8)", "description": "

Each graph will contain n vertices.

", "templateType": "anything", "can_override": false}, "vertex_perm": {"name": "vertex_perm", "group": "Ungrouped variables", "definition": "perm(shuffle(0..n-1))", "description": "

The vertices of graph 2 will be mapped by this permutation to those of graph 1.

", "templateType": "anything", "can_override": false}, "diff_degree": {"name": "diff_degree", "group": "Ungrouped variables", "definition": "let(\n degrees, vertex_degrees(g1),\n d, max(degrees),\n v, indices(degrees,d)[0],\n edges, edges(g1),\n e, random(filter(not (v in ends(e)),e,edges)),\n nedges,map(if(e2=e,edge(v,to(e)),e2),e2,edges),\n graph(nedges)\n)", "description": "

Take g1 and find the vertex $v$ with highest degree. Move an edge connecting two other vertices so that one end is on $v$ instead. This changes the degree sequence, so produces a graph not isomorphic to g1.

", "templateType": "anything", "can_override": false}, "fewer_edges": {"name": "fewer_edges", "group": "Ungrouped variables", "definition": "let(\n edges, edges(g1),\n degrees,vertex_degrees(g1),\n ok_edges,filter(degrees[from(e)]>1 and degrees[to(e)]>1,e,edges),\n e,random(ok_edges),\n graph(filter(e2<>e,e2,edges))\n)", "description": "

Remove an edge from g1 to produce a non-isomorphic graph. Only edges connecting vertices with degree at least 2 are considered, so the graph remains connected.

", "templateType": "anything", "can_override": false}, "g2": {"name": "g2", "group": "Ungrouped variables", "definition": "set_vertex_labels(\n auto_layout(permute_vertices(\n vertex_perm, \n if(is_isomorphic,\n graph(edges(g1)),\n random(diff_degree, fewer_edges)\n )\n ))\n ,\n map(string(x),x,1..n)\n)", "description": "

The graph $\\Gamma_2$. If it should be isomorphic, just take g1, otherwise pick from the non-isomorphic options.

\n

Permute the vertices according to the permutation vertex_perm, and lay the vertices out again.

", "templateType": "anything", "can_override": false}, "advice_none": {"name": "advice_none", "group": "Ungrouped variables", "definition": "\"

Therefore there is no isomorphism between $\\\\Gamma_1$ and $\\\\Gamma_2$.

\"", "description": "

The advice shown if the graphs are not isomorphic.

", "templateType": "long string", "can_override": false}, "advice_isomorphism": {"name": "advice_isomorphism", "group": "Ungrouped variables", "definition": "\"

Since these are all the same for $\\\\Gamma_1$ and $\\\\Gamma_2$, we might be able to find an isomorphism. Indeed, we can map vertex 1 of $\\\\Gamma_1$ to vertex {vertex_perm[1]} of $\\\\Gamma_2$, we can map vertex 2 to vertex {vertex_perm[2]}, vertex 3 to vertex {vertex_perm[3]}, and so on. Therefore a valid isomorphism is

\\n

\\\\[ \\\\var{twoline(vertex_perm)} \\\\]

\\n

(Note: there may be more than one isomorphism.)

\"", "description": "

The advice shown if the graphs are isomorphic.

", "templateType": "long string", "can_override": false}, "advice": {"name": "advice", "group": "Ungrouped variables", "definition": "if(is_isomorphic, advice_isomorphism, advice_none)", "description": "

The final line of the advice, describing the isomorphism if there is one, or stating that there is none.

", "templateType": "anything", "can_override": false}, "is_isomorphic": {"name": "is_isomorphic", "group": "Ungrouped variables", "definition": "random(true,false)", "description": "

Should $\\Gamma_1$ and $\\Gamma_2$ be isomorphic?

", "templateType": "anything", "can_override": false}}, "variablesTest": {"condition": "", "maxRuns": 100}, "ungrouped_variables": ["is_isomorphic", "n", "g1", "diff_degree", "fewer_edges", "g2", "vertex_perm", "advice_none", "advice_isomorphism", "advice"], "variable_groups": [], "functions": {}, "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": "

Compare the properties of $\\Gamma_1$ and $\\Gamma_2$.

\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n
Number of verticesNumber of edgesDegree sequence
$\\Gamma_1$[[0]][[2]][[4]]
$\\Gamma_2$[[1]][[3]][[5]]
", "gaps": [{"type": "numberentry", "useCustomName": true, "customName": "Vertices in $\\Gamma_1$", "marks": 1, "scripts": {}, "customMarkingAlgorithm": "", "extendBaseMarkingAlgorithm": true, "unitTests": [], "showCorrectAnswer": true, "showFeedbackIcon": true, "variableReplacements": [], "variableReplacementStrategy": "originalfirst", "nextParts": [], "suggestGoingBack": false, "adaptiveMarkingPenalty": 0, "exploreObjective": null, "minValue": "len(vertices(g1))", "maxValue": "len(vertices(g1))", "correctAnswerFraction": false, "allowFractions": false, "mustBeReduced": false, "mustBeReducedPC": 0, "showFractionHint": true, "notationStyles": ["plain", "en", "si-en"], "correctAnswerStyle": "plain"}, {"type": "numberentry", "useCustomName": true, "customName": "Vertices in $\\Gamma_2$", "marks": 1, "scripts": {}, "customMarkingAlgorithm": "", "extendBaseMarkingAlgorithm": true, "unitTests": [], "showCorrectAnswer": true, "showFeedbackIcon": true, "variableReplacements": [], "variableReplacementStrategy": "originalfirst", "nextParts": [], "suggestGoingBack": false, "adaptiveMarkingPenalty": 0, "exploreObjective": null, "minValue": "len(vertices(g2))", "maxValue": "len(vertices(g2))", "correctAnswerFraction": false, "allowFractions": false, "mustBeReduced": false, "mustBeReducedPC": 0, "showFractionHint": true, "notationStyles": ["plain", "en", "si-en"], "correctAnswerStyle": "plain"}, {"type": "numberentry", "useCustomName": true, "customName": "Edges in $\\Gamma_1$", "marks": 1, "scripts": {}, "customMarkingAlgorithm": "", "extendBaseMarkingAlgorithm": true, "unitTests": [], "showCorrectAnswer": true, "showFeedbackIcon": true, "variableReplacements": [], "variableReplacementStrategy": "originalfirst", "nextParts": [], "suggestGoingBack": false, "adaptiveMarkingPenalty": 0, "exploreObjective": null, "minValue": "len(edges(g1))", "maxValue": "len(edges(g1))", "correctAnswerFraction": false, "allowFractions": false, "mustBeReduced": false, "mustBeReducedPC": 0, "showFractionHint": true, "notationStyles": ["plain", "en", "si-en"], "correctAnswerStyle": "plain"}, {"type": "numberentry", "useCustomName": true, "customName": "Edges in $\\Gamma_2$", "marks": 1, "scripts": {}, "customMarkingAlgorithm": "", "extendBaseMarkingAlgorithm": true, "unitTests": [], "showCorrectAnswer": true, "showFeedbackIcon": true, "variableReplacements": [], "variableReplacementStrategy": "originalfirst", "nextParts": [], "suggestGoingBack": false, "adaptiveMarkingPenalty": 0, "exploreObjective": null, "minValue": "len(edges(g2))", "maxValue": "len(edges(g2))", "correctAnswerFraction": false, "allowFractions": false, "mustBeReduced": false, "mustBeReducedPC": 0, "showFractionHint": true, "notationStyles": ["plain", "en", "si-en"], "correctAnswerStyle": "plain"}, {"type": "list-of-numbers", "useCustomName": true, "customName": "Degree sequence of $\\Gamma_1$", "marks": 1, "scripts": {}, "customMarkingAlgorithm": "", "extendBaseMarkingAlgorithm": true, "unitTests": [], "showCorrectAnswer": true, "showFeedbackIcon": true, "variableReplacements": [], "variableReplacementStrategy": "originalfirst", "nextParts": [], "suggestGoingBack": false, "adaptiveMarkingPenalty": 0, "exploreObjective": null, "settings": {"correctAnswer": "sort(vertex_degrees(g1))", "allowFractions": false, "correctAnswerFractions": false, "isSet": false, "show_input_hint": false}}, {"type": "list-of-numbers", "useCustomName": true, "customName": "Degree sequence of $\\Gamma_2$", "marks": 1, "scripts": {}, "customMarkingAlgorithm": "", "extendBaseMarkingAlgorithm": true, "unitTests": [], "showCorrectAnswer": true, "showFeedbackIcon": true, "variableReplacements": [], "variableReplacementStrategy": "originalfirst", "nextParts": [], "suggestGoingBack": false, "adaptiveMarkingPenalty": 0, "exploreObjective": null, "settings": {"correctAnswer": "sort(vertex_degrees(g2))", "allowFractions": false, "correctAnswerFractions": false, "isSet": false, "show_input_hint": 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": "

Are the graphs $\\Gamma_1$ and $\\Gamma_2$ isomorphic?

\n

[[0]]

\n

If so, write down an isomorphism $\\varphi : \\Gamma_1 \\to \\Gamma_2$.

\n

If no such isomorphism exists, write 0 in every box below.

\n

[[1]]

", "gaps": [{"type": "yes-no", "useCustomName": true, "customName": "Is there an isomorphism?", "marks": 1, "scripts": {}, "customMarkingAlgorithm": "", "extendBaseMarkingAlgorithm": true, "unitTests": [], "showCorrectAnswer": true, "showFeedbackIcon": true, "variableReplacements": [], "variableReplacementStrategy": "originalfirst", "nextParts": [], "suggestGoingBack": false, "adaptiveMarkingPenalty": 0, "exploreObjective": null, "settings": {"correct_answer_expr": "is_isomorphic"}}, {"type": "write-a-permutation-in-two-line-form", "useCustomName": true, "customName": "Write an isomorphism", "marks": 1, "scripts": {}, "customMarkingAlgorithm": "all_zero:\n all(map(x=0,x,student_numbers))\n\nstudent_permutation_is_isomorphism:\n let(\n a1, adjacency_matrix(g1),\n a2, adjacency_matrix(g2),\n p, student_permutation,\n all(map(\n all(map(a1[y-1][x-1]=a2[p[y]-1][p[x]-1],x,1..n)),\n y,\n 1..n\n ))\n )\n\nmark:\n if(is_isomorphic,\n correctif(student_permutation_is_isomorphism)\n ,\n correctif(all_zero)\n )", "extendBaseMarkingAlgorithm": true, "unitTests": [], "showCorrectAnswer": true, "showFeedbackIcon": true, "variableReplacements": [], "variableReplacementStrategy": "originalfirst", "nextParts": [], "suggestGoingBack": false, "adaptiveMarkingPenalty": 0, "exploreObjective": null, "settings": {"correctAnswer": "if(is_isomorphic,\n vertex_perm\n,\n repeat(0,n+1)\n)", "size": "n"}}], "sortAnswers": false}], "partsMode": "all", "maxMarks": 0, "objectives": [], "penalties": [], "objectiveVisibility": "always", "penaltyVisibility": "always"}, {"name": "Graphs: Match adjacency matrix to a graph", "extensions": ["graph-theory-v1"], "custom_part_types": [], "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": "Chris Graham", "profile_url": "https://numbas.mathcentre.ac.uk/accounts/profile/369/"}, {"name": "Sam Mutter", "profile_url": "https://numbas.mathcentre.ac.uk/accounts/profile/9360/"}], "tags": [], "metadata": {"description": "

Alternative version of Graphs: Match graph to its adjacency matrix, where the student must match an adjacency matrix to a graph.

", "licence": "Creative Commons Attribution 4.0 International"}, "statement": "

Consider the {number_of_graphs} graphs drawn below, each with vertices labelled from $1$ to $\\var{n+1}$.

\n\n\n\n\n\n\n\n\n\n\n\n\n\n
Graph $G_1$:Graph $G_2$:Graph $G_3$:
{graphs[0]}{graphs[1]}{graphs[2]}
\n

You will be shown an adjacency matrix below. The $i$th row or column of the matrix corresponds to vertex labelled $i$.

\n

Match the matrix to the graph it describes the adjacency of.

", "advice": "

The adjacency matrix $M$ of a graph $G$ has $(i,j)$th entry $1$ whenever there is an edge from vertex $i$ to vertex $j$.

\n

The $(i,j)$th entry is $0$ otherwise.

", "rulesets": {}, "builtin_constants": {"e": true, "pi,\u03c0": true, "i": true}, "constants": [], "variables": {"graphs": {"name": "graphs", "group": "Ungrouped variables", "definition": "map(\n draw_graph_from_adjacency(matrices[q], map(string(i), i, 1..n+1)), \n q, 0..number_of_graphs - 1\n)", "description": "

Graphs built fron the adjacency matrices

", "templateType": "anything", "can_override": false}, "matrices": {"name": "matrices", "group": "Ungrouped variables", "definition": "map(\n matrix(reorder( \n [reorder(a[q][0], vertex_perm)] +\n map(\n reorder(map(a[q][i][j-i], i, 0..j-1) + a[q][j], vertex_perm), j, 1..n\n ), vertex_perm\n )), q, 0..number_of_graphs - 1\n)", "description": "

The qth matrix takes entries from a[q] as its upper triangle, then duplicates this for the bottom triangle to make a symmetric matrix.

", "templateType": "anything", "can_override": false}, "n": {"name": "n", "group": "Ungrouped variables", "definition": "7", "description": "

Each graph will contain n+1 vertices

", "templateType": "anything", "can_override": false}, "a": {"name": "a", "group": "Ungrouped variables", "definition": "map(\n [first_row[q]] +\n map([0] + repeat(random(0,0,0,1,1), n-j), j, 1..n-1)\n + [[0]],\n q, 0..number_of_graphs - 1\n)", "description": "

The top-right triangle of the adjacency matrices. The bottom-left triangle will be the transpose of this, so that the matrices are symmetrical.

\n

The first rows are all distinct, so no two adjacency matrices are the same.

\n

Change the number of 0s and 1s to get a more/less dense matrix.

", "templateType": "anything", "can_override": false}, "number_of_graphs": {"name": "number_of_graphs", "group": "Ungrouped variables", "definition": "3", "description": "

The number of graphs displayed in the question. Each adjacency matrix correctly matched to its graph will score a point.

\n

This must be less than or equal to the number of vertices n+1.

", "templateType": "anything", "can_override": false}, "graph_mat_pairs": {"name": "graph_mat_pairs", "group": "Ungrouped variables", "definition": "shuffle(\n map(\n [\n 'graph': graphs[i],\n 'matrix': matrices[i],\n 'marks': 4*id(number_of_graphs)[i]\n ], i, 0..number_of_graphs - 1\n )\n)", "description": "

The graphs, matched with their adjacency matrices. The 'marks' column will form the marking matrix

", "templateType": "anything", "can_override": false}, "first_row": {"name": "first_row", "group": "Ungrouped variables", "definition": "shuffle(\n flatten(map(\n map(vector(id(n+1)[i]) + vector(id(n+1)[j]), j, i+1..n), i, 1..n)\n )\n)", "description": "

To ensure no two adjacency matrices are the same, the first row will be taken from this list.

", "templateType": "anything", "can_override": false}, "vertex_perm": {"name": "vertex_perm", "group": "Ungrouped variables", "definition": "shuffle(0..n)", "description": "

The labels of vertices will be permuted. This is so it isn't obvious that the first row of the adjacency matrices are different.

", "templateType": "anything", "can_override": false}}, "variablesTest": {"condition": "", "maxRuns": 100}, "ungrouped_variables": ["graphs", "matrices", "n", "a", "number_of_graphs", "graph_mat_pairs", "first_row", "vertex_perm"], "variable_groups": [], "functions": {}, "preamble": {"js": "", "css": ""}, "parts": [{"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, "prompt": "

$A = \\var{graph_mat_pairs[0]['matrix']}$.

\n

Select which graph $A$ is the adjacency matrix for.

", "minMarks": 0, "maxMarks": 0, "shuffleChoices": false, "displayType": "radiogroup", "displayColumns": 0, "showCellAnswerState": true, "choices": ["$G_1$", "$G_2$", "$G_3$"], "matrix": "graph_mat_pairs[0]['marks']"}], "partsMode": "all", "maxMarks": 0, "objectives": [], "penalties": [], "objectiveVisibility": "always", "penaltyVisibility": "always"}, {"name": "Graphs: Write the adjacency matrix of this graph", "extensions": ["graph-theory-v1"], "custom_part_types": [], "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": "Sam Mutter", "profile_url": "https://numbas.mathcentre.ac.uk/accounts/profile/9360/"}], "tags": [], "metadata": {"description": "

The student is shown one graph, and asked to type the adjacency matrix

", "licence": "Creative Commons Attribution 4.0 International"}, "statement": "

You will be shown three graphs below, each with vertices labelled from $1$ to $\\var{n+1}$.

\n

Consider the following graph:

\n

{max_width(30,graph)}

\n

Write down the adjacency matrix of this graph.

\n

The $i$th row or column of your matrix should correspond to the vertex labelled $i$.

", "advice": "

The adjacency matrix $M$ of a graph $G$ has $ij$th entry $1$ whenever there is an edge from vertex $i$ to vertex $j$.

\n

The $ij$th entry is $0$ otherwise.

", "rulesets": {}, "builtin_constants": {"e": true, "pi,\u03c0": true, "i": true}, "constants": [], "variables": {"graph": {"name": "graph", "group": "Ungrouped variables", "definition": "draw_graph_from_adjacency(mat, map(string(i), i, 1..n+1))", "description": "

Graphs built fron the adjacency matrices

", "templateType": "anything", "can_override": false}, "mat": {"name": "mat", "group": "Ungrouped variables", "definition": "matrix(reorder( \n [reorder(a[0], vertex_perm)] +\n map(\n reorder(map(a[i][j-i], i, 0..j-1) + a[j], vertex_perm), j, 1..n\n ), vertex_perm\n ))", "description": "

The qth matrix takes entries from a[q] as its upper triangle, then duplicates this for the bottom triangle to make a symmetric matrix.

", "templateType": "anything", "can_override": false}, "n": {"name": "n", "group": "Ungrouped variables", "definition": "7", "description": "

Each graph will contain n+1 vertices.

\n

n should be at least 4. My view is that it looks good when n is around 7 to 8.

", "templateType": "anything", "can_override": false}, "a": {"name": "a", "group": "Ungrouped variables", "definition": "map([0] + repeat(random(0,0,0,1,1), n-j), j, 0..n-1)\n+ [[0]]\n", "description": "

The top-right triangle of the adjacency matrices. The bottom-left triangle will be the transpose of this, so that the matrices are symmetrical.

\n

The first rows are all distinct, so no two adjacency matrices are the same.

\n

Change the number of 0s and 1s to get a more/less dense matrix.

", "templateType": "anything", "can_override": false}, "vertex_perm": {"name": "vertex_perm", "group": "Ungrouped variables", "definition": "shuffle(0..n)", "description": "

The labels of vertices will be permuted. This is so it isn't obvious that the first row of the adjacency matrices are different.

", "templateType": "anything", "can_override": false}}, "variablesTest": {"condition": "", "maxRuns": 100}, "ungrouped_variables": ["n", "a", "vertex_perm", "graph", "mat"], "variable_groups": [], "functions": {}, "preamble": {"js": "", "css": ""}, "parts": [{"type": "matrix", "useCustomName": false, "customName": "", "marks": "4", "scripts": {}, "customMarkingAlgorithm": "", "extendBaseMarkingAlgorithm": true, "unitTests": [], "showCorrectAnswer": true, "showFeedbackIcon": true, "variableReplacements": [], "variableReplacementStrategy": "originalfirst", "nextParts": [], "suggestGoingBack": false, "adaptiveMarkingPenalty": 0, "exploreObjective": null, "correctAnswer": "{mat}", "correctAnswerFractions": false, "numRows": "{n+1}", "numColumns": "{n+1}", "allowResize": false, "tolerance": 0, "markPerCell": true, "allowFractions": false, "minColumns": 1, "maxColumns": 0, "minRows": 1, "maxRows": 0}], "partsMode": "all", "maxMarks": 0, "objectives": [], "penalties": [], "objectiveVisibility": "always", "penaltyVisibility": "always"}, {"name": "Prim's algorithm", "extensions": ["graph-theory"], "custom_part_types": [], "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/"}], "tags": [], "metadata": {"description": "

The student is given a connected graph and must find a minimum spanning tree.

", "licence": "Creative Commons Attribution 4.0 International"}, "statement": "

$G$ is a graph with {len(vertices(g))} vertices.

\n

{max_height(30,max_width(30,draw(g)))}

\n

The table below gives the weights of the edges in $G$:

\n

{weight_table(g)}

", "advice": "

{prims_algorithm_working(g)}

", "rulesets": {}, "builtin_constants": {"e": true, "pi,\u03c0": true, "i": true}, "constants": [], "variables": {"g": {"name": "g", "group": "Ungrouped variables", "definition": "let(\n vertices, vertices(unweighted_g),\n weights,map(round(len(vertices[from(e)]-vertices[to(e)])),e,edges(unweighted_g)),\n \n set_edge_weights(unweighted_g,weights)\n)\n", "description": "", "templateType": "anything", "can_override": false}, "vertex_labels": {"name": "vertex_labels", "group": "Ungrouped variables", "definition": "map(upper(letterordinal(i)),i,0..n-1)", "description": "", "templateType": "anything", "can_override": false}, "n": {"name": "n", "group": "Ungrouped variables", "definition": "7", "description": "", "templateType": "anything", "can_override": false}, "min_spanning_tree": {"name": "min_spanning_tree", "group": "Ungrouped variables", "definition": "map(ends(e),e,prims_algorithm(g))", "description": "", "templateType": "anything", "can_override": false}, "min_spanning_tree_marking_matrix": {"name": "min_spanning_tree_marking_matrix", "group": "Ungrouped variables", "definition": "map(\n map(\n award(1,[x,y] in min_spanning_tree or [y,x] in min_spanning_tree),\n x,\n 0..n-1\n ),\n y,\n 0..n-1\n)", "description": "", "templateType": "anything", "can_override": false}, "minimal_weight": {"name": "minimal_weight", "group": "Ungrouped variables", "definition": "sum(map(award(weight_matrix[x][y],[x,y] in min_spanning_tree), [x,y], product(0..n,2)))", "description": "", "templateType": "anything", "can_override": false}, "weight_matrix": {"name": "weight_matrix", "group": "Ungrouped variables", "definition": "weight_matrix(g)", "description": "", "templateType": "anything", "can_override": false}, "unweighted_g": {"name": "unweighted_g", "group": "Ungrouped variables", "definition": "let(g,random_planar_graph(n),\n auto_layout(\n set_vertex_labels(g,\n vertex_labels\n )\n )\n)", "description": "", "templateType": "anything", "can_override": false}, "entry_layout": {"name": "entry_layout", "group": "Ungrouped variables", "definition": "let(\n a,adjacency_matrix(g),\n map(\n map(i>j and a[i][j]>0, j, 0..n),\n i,\n 0..n\n )\n)", "description": "", "templateType": "anything", "can_override": false}}, "variablesTest": {"condition": "", "maxRuns": 100}, "ungrouped_variables": ["n", "vertex_labels", "g", "min_spanning_tree", "min_spanning_tree_marking_matrix", "weight_matrix", "minimal_weight", "unweighted_g", "entry_layout"], "variable_groups": [], "functions": {}, "preamble": {"js": "", "css": ".graph { min-height: 10em; }"}, "parts": [{"type": "m_n_x", "useCustomName": false, "customName": "", "marks": 0, "scripts": {}, "customMarkingAlgorithm": "student_weight: sum(map(award(weight_matrix[x][y],studentAnswer[x][y]), [x,y], tick_indexes))\n\nstudent_graph: graph(matrix(map(map(award(1,x),x,row),row,studentAnswer)), vertices(g))\n\nstudent_graph_is_connected:\n assert(is_connected(student_graph), \n incorrect(\"Your graph is not a spanning tree.\");\n end()\n )\n\nmark:\n feedback(\"Here's your graph:\");\n feedback(draw(student_graph));\n apply(student_graph_is_connected);\n if(student_weight <= minimal_weight,\n correct()\n ,\n add_credit(1/6, \"The weight of your tree is {student_weight}. You could do better.\")\n )", "extendBaseMarkingAlgorithm": true, "unitTests": [], "showCorrectAnswer": true, "showFeedbackIcon": true, "variableReplacements": [], "variableReplacementStrategy": "originalfirst", "nextParts": [], "suggestGoingBack": false, "adaptiveMarkingPenalty": 0, "exploreObjective": null, "prompt": "

Find a minimum spanning tree for $G$.

\n

For each edge in your minimum spanning tree, tick the box corresponding to the vertices that the edge joins.

", "minMarks": 0, "maxMarks": "6", "minAnswers": 0, "maxAnswers": 0, "shuffleChoices": false, "shuffleAnswers": false, "displayType": "checkbox", "warningType": "none", "showCellAnswerState": false, "markingMethod": "all-or-nothing", "choices": "vertex_labels", "matrix": "min_spanning_tree_marking_matrix", "layout": {"type": "expression", "expression": "entry_layout"}, "answers": "vertex_labels"}], "partsMode": "all", "maxMarks": 0, "objectives": [], "penalties": [], "objectiveVisibility": "always", "penaltyVisibility": "always"}]}], "allowPrinting": true, "navigation": {"allowregen": true, "reverse": true, "browse": true, "allowsteps": true, "showfrontpage": false, "showresultspage": "oncompletion", "navigatemode": "menu", "onleave": {"action": "none", "message": ""}, "preventleave": false, "startpassword": "", "allowAttemptDownload": false, "downloadEncryptionKey": ""}, "timing": {"allowPause": true, "timeout": {"action": "none", "message": ""}, "timedwarning": {"action": "none", "message": ""}}, "feedback": {"showactualmark": true, "showtotalmark": true, "showanswerstate": true, "allowrevealanswer": true, "advicethreshold": 0, "intro": "", "end_message": "", "reviewshowscore": true, "reviewshowfeedback": true, "reviewshowexpectedanswer": true, "reviewshowadvice": true, "feedbackmessages": []}, "diagnostic": {"knowledge_graph": {"topics": [], "learning_objectives": []}, "script": "diagnosys", "customScript": ""}, "contributors": [{"name": "Christian Lawson-Perfect", "profile_url": "https://numbas.mathcentre.ac.uk/accounts/profile/7/"}], "extensions": ["graph-theory", "graph-theory-v1", "permutations"], "custom_part_types": [{"source": {"pk": 2, "author": {"name": "Christian Lawson-Perfect", "pk": 7}, "edit_page": "/part_type/2/edit"}, "name": "List of numbers", "short_name": "list-of-numbers", "description": "

The answer is a comma-separated list of numbers.

\n

The list is marked correct if each number occurs the same number of times as in the expected answer, and no extra numbers are present.

\n

You can optionally treat the answer as a set, so the number of occurrences doesn't matter, only whether each number is included or not.

", "help_url": "", "input_widget": "string", "input_options": {"correctAnswer": "join(\n if(settings[\"correctAnswerFractions\"],\n map(let([a,b],rational_approximation(x), string(a/b)),x,settings[\"correctAnswer\"])\n ,\n settings[\"correctAnswer\"]\n ),\n settings[\"separator\"] + \" \"\n)", "hint": {"static": false, "value": "if(settings[\"show_input_hint\"],\n \"Enter a list of numbers separated by {settings['separator']}.\",\n \"\"\n)"}, "allowEmpty": {"static": true, "value": true}}, "can_be_gap": true, "can_be_step": true, "marking_script": "bits:\nlet(b,filter(x<>\"\",x,split(studentAnswer,settings[\"separator\"])),\n if(isSet,list(set(b)),b)\n)\n\nexpected_numbers:\nlet(l,settings[\"correctAnswer\"] as \"list\",\n if(isSet,list(set(l)),l)\n)\n\nvalid_numbers:\nif(all(map(not isnan(x),x,interpreted_answer)),\n true,\n let(index,filter(isnan(interpreted_answer[x]),x,0..len(interpreted_answer)-1)[0], wrong, bits[index],\n warn(wrong+\" is not a valid number\");\n fail(wrong+\" is not a valid number.\")\n )\n )\n\nis_sorted:\nassert(sort(interpreted_answer)=interpreted_answer,\n multiply_credit(0.5,\"Not in order\")\n )\n\nincluded:\nmap(\n let(\n num_student,len(filter(x=y,y,interpreted_answer)),\n num_expected,len(filter(x=y,y,expected_numbers)),\n switch(\n num_student=num_expected,\n true,\n num_studentThe separate items in the student's answer

", "definition": "let(b,filter(x<>\"\",x,split(studentAnswer,settings[\"separator\"])),\n if(isSet,list(set(b)),b)\n)"}, {"name": "expected_numbers", "description": "", "definition": "let(l,settings[\"correctAnswer\"] as \"list\",\n if(isSet,list(set(l)),l)\n)"}, {"name": "valid_numbers", "description": "

Is every number in the student's list valid?

", "definition": "if(all(map(not isnan(x),x,interpreted_answer)),\n true,\n let(index,filter(isnan(interpreted_answer[x]),x,0..len(interpreted_answer)-1)[0], wrong, bits[index],\n warn(wrong+\" is not a valid number\");\n fail(wrong+\" is not a valid number.\")\n )\n )"}, {"name": "is_sorted", "description": "

Are the student's answers in ascending order?

", "definition": "assert(sort(interpreted_answer)=interpreted_answer,\n multiply_credit(0.5,\"Not in order\")\n )"}, {"name": "included", "description": "

Is each number in the expected answer present in the student's list the correct number of times?

", "definition": "map(\n let(\n num_student,len(filter(x=y,y,interpreted_answer)),\n num_expected,len(filter(x=y,y,expected_numbers)),\n switch(\n num_student=num_expected,\n true,\n num_studentHas every number been included the right number of times?

", "definition": "all(included)"}, {"name": "no_extras", "description": "

True if the student's list doesn't contain any numbers that aren't in the expected answer.

", "definition": "if(all(map(x in expected_numbers, x, interpreted_answer)),\n true\n ,\n incorrect(\"Your answer contains \"+extra_numbers[0]+\" but should not.\");\n false\n )"}, {"name": "interpreted_answer", "description": "A value representing the student's answer to this part.", "definition": "if(lower(studentAnswer) in [\"empty\",\"\u2205\"],[],\n map(\n if(settings[\"allowFractions\"],parsenumber_or_fraction(x,notationStyles), parsenumber(x,notationStyles))\n ,x\n ,bits\n )\n)"}, {"name": "mark", "description": "This is the main marking note. It should award credit and provide feedback based on the student's answer.", "definition": "if(studentanswer=\"\",fail(\"You have not entered an answer\"),false);\napply(valid_numbers);\napply(included);\napply(no_extras);\ncorrectif(all_included and no_extras)"}, {"name": "notationStyles", "description": "", "definition": "[\"en\"]"}, {"name": "isSet", "description": "

Should the answer be considered as a set, so the number of times an element occurs doesn't matter?

", "definition": "settings[\"isSet\"]"}, {"name": "extra_numbers", "description": "

Numbers included in the student's answer that are not in the expected list.

", "definition": "filter(not (x in expected_numbers),x,interpreted_answer)"}], "settings": [{"name": "correctAnswer", "label": "Correct answer", "help_url": "", "hint": "The list of numbers that the student should enter. The order does not matter.", "input_type": "code", "default_value": "", "evaluate": true}, {"name": "allowFractions", "label": "Allow the student to enter fractions?", "help_url": "", "hint": "", "input_type": "checkbox", "default_value": false}, {"name": "correctAnswerFractions", "label": "Display the correct answers as fractions?", "help_url": "", "hint": "", "input_type": "checkbox", "default_value": false}, {"name": "isSet", "label": "Is the answer a set?", "help_url": "", "hint": "If ticked, the number of times an element occurs doesn't matter, only whether it's included at all.", "input_type": "checkbox", "default_value": false}, {"name": "show_input_hint", "label": "Show the input hint?", "help_url": "", "hint": "", "input_type": "checkbox", "default_value": true}, {"name": "separator", "label": "Separator", "help_url": "", "hint": "The substring that should separate items in the student's list", "input_type": "string", "default_value": ",", "subvars": false}], "public_availability": "always", "published": true, "extensions": []}, {"source": {"pk": 197, "author": {"name": "Christian Lawson-Perfect", "pk": 7}, "edit_page": "/part_type/197/edit"}, "name": "Write a permutation in two-line form", "short_name": "write-a-permutation-in-two-line-form", "description": "

The student must write out a permutation (an element of $S_n$) in two-line form: the top line always contains the numbers 1 to $n$, and on the bottom line they must write the numbers that they are mapped to.

", "help_url": "", "input_widget": "matrix", "input_options": {"correctAnswer": "matrix(map(settings[\"correctAnswer\"][i],i,1..settings[\"size\"]))", "hint": {"static": true, "value": ""}, "allowResize": {"static": true, "value": false}, "numRows": {"static": true, "value": 1}, "numColumns": {"static": false, "value": "settings[\"size\"]"}, "parseCells": {"static": true, "value": true}, "allowedNotationStyles": {"static": true, "value": ["plain"]}, "allowFractions": {"static": true, "value": false}, "showBrackets": {"static": true, "value": true}, "rowHeaders": {"static": false, "value": "[]"}, "columnHeaders": {"static": false, "value": "map(string(n),n,1..settings[\"size\"])"}}, "can_be_gap": true, "can_be_step": true, "marking_script": "mark:\napply(valid_permutation);\ncorrectif(student_permutation=settings[\"correctAnswer\"])\n\nstudent_numbers:\nlist(studentAnswer[0])\n\nstudent_permutation:\npermutation(map(x-1,x,student_numbers))\n\nvalid_permutation:\n assert(all(map(isint(x) and x>=1 and x<=settings[\"size\"], x, student_numbers)),\n fail(\"Your answer is not a valid permutation: each entry must be one of the numbers 1 \u2026 {settings['size']}.\")\n );\n assert(len(set(student_numbers))=settings[\"size\"],\n fail(\"Your answer is not a valid permutation: some entries occur more than once.\")\n )\n\ninterpreted_answer:\nstudent_permutation", "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(valid_permutation);\ncorrectif(student_permutation=settings[\"correctAnswer\"])"}, {"name": "student_numbers", "description": "

The numbers that the student typed.

", "definition": "list(studentAnswer[0])"}, {"name": "student_permutation", "description": "", "definition": "permutation(map(x-1,x,student_numbers))"}, {"name": "valid_permutation", "description": "", "definition": " assert(all(map(isint(x) and x>=1 and x<=settings[\"size\"], x, student_numbers)),\n fail(\"Your answer is not a valid permutation: each entry must be one of the numbers 1 \u2026 {settings['size']}.\")\n );\n assert(len(set(student_numbers))=settings[\"size\"],\n fail(\"Your answer is not a valid permutation: some entries occur more than once.\")\n )"}, {"name": "interpreted_answer", "description": "A value representing the student's answer to this part.", "definition": "student_permutation"}], "settings": [{"name": "correctAnswer", "label": "Correct answer", "help_url": "", "hint": "", "input_type": "code", "default_value": "", "evaluate": true}, {"name": "size", "label": "Size", "help_url": "", "hint": "", "input_type": "code", "default_value": "", "evaluate": true}], "public_availability": "always", "published": true, "extensions": []}, {"source": {"pk": 1, "author": {"name": "Christian Lawson-Perfect", "pk": 7}, "edit_page": "/part_type/1/edit"}, "name": "Yes/no", "short_name": "yes-no", "description": "

The student is shown two radio choices: \"Yes\" and \"No\". One of them is correct.

", "help_url": "", "input_widget": "radios", "input_options": {"correctAnswer": "if(eval(settings[\"correct_answer_expr\"]), 0, 1)", "hint": {"static": true, "value": ""}, "choices": {"static": true, "value": ["Yes", "No"]}}, "can_be_gap": true, "can_be_step": true, "marking_script": "mark:\nif(studentanswer=correct_answer,\n correct(),\n incorrect()\n)\n\ninterpreted_answer:\nstudentAnswer=0\n\ncorrect_answer:\nif(eval(settings[\"correct_answer_expr\"]),0,1)", "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": "if(studentanswer=correct_answer,\n correct(),\n incorrect()\n)"}, {"name": "interpreted_answer", "description": "A value representing the student's answer to this part.", "definition": "studentAnswer=0"}, {"name": "correct_answer", "description": "", "definition": "if(eval(settings[\"correct_answer_expr\"]),0,1)"}], "settings": [{"name": "correct_answer_expr", "label": "Is the answer \"Yes\"?", "help_url": "", "hint": "An expression which evaluates to true or false.", "input_type": "mathematical_expression", "default_value": "true", "subvars": false}], "public_availability": "always", "published": true, "extensions": []}], "resources": []}