// Numbas version: exam_results_page_options {"name": "Basic Set Theory: power set", "extensions": [], "custom_part_types": [], "resources": [], "navigation": {"allowregen": true, "showfrontpage": false, "preventleave": false, "typeendtoleave": false}, "question_groups": [{"pickingStrategy": "all-ordered", "questions": [{"rulesets": {}, "preamble": {"css": "", "js": ""}, "parts": [{"answer": "{PB}", "useCustomName": false, "customMarkingAlgorithm": "", "marks": 1, "variableReplacements": [], "vsetRangePoints": 5, "customName": "", "vsetRange": [0, 1], "prompt": "

What is the power set of $\\left\\{\\var{listB[0]},\\var{listB[1]}\\right\\}$?

", "variableReplacementStrategy": "originalfirst", "failureRate": 1, "checkingType": "absdiff", "steps": [{"answer": "set()", "useCustomName": false, "customMarkingAlgorithm": "", "marks": 1, "variableReplacements": [], "vsetRangePoints": 5, "customName": "", "vsetRange": [0, 1], "prompt": "

First we look at all the subsets containing zero elements. This is the empty set $\\left\\{\\right\\}$ and it is an element of any power set. Enter the empty set below using the NUMBAS syntax, which is set().

", "variableReplacementStrategy": "originalfirst", "failureRate": 1, "checkingType": "absdiff", "adaptiveMarkingPenalty": 0, "valuegenerators": [], "extendBaseMarkingAlgorithm": true, "checkVariableNames": false, "unitTests": [], "showPreview": true, "type": "jme", "scripts": {}, "checkingAccuracy": 0.001, "showCorrectAnswer": true, "showFeedbackIcon": true}, {"answer": "set({listB[0]})", "useCustomName": false, "customMarkingAlgorithm": "", "marks": 1, "variableReplacements": [], "vsetRangePoints": 5, "customName": "", "vsetRange": [0, 1], "prompt": "

Next we look at all the subsets containing exactly one element, such as $\\left\\{\\var{listB[0]}\\right\\}$. Enter this using the NUMBAS syntax set({listB[0]}).

", "variableReplacementStrategy": "originalfirst", "failureRate": 1, "checkingType": "absdiff", "adaptiveMarkingPenalty": 0, "valuegenerators": [], "extendBaseMarkingAlgorithm": true, "checkVariableNames": false, "unitTests": [], "showPreview": true, "type": "jme", "scripts": {}, "checkingAccuracy": 0.001, "showCorrectAnswer": true, "showFeedbackIcon": true}, {"answer": "set({listB[1]})", "useCustomName": false, "customMarkingAlgorithm": "", "marks": 1, "variableReplacements": [], "vsetRangePoints": 5, "customName": "", "vsetRange": [0, 1], "prompt": "

What is the other subset that that contains exactly one element?

", "variableReplacementStrategy": "originalfirst", "failureRate": 1, "checkingType": "absdiff", "adaptiveMarkingPenalty": 0, "valuegenerators": [], "extendBaseMarkingAlgorithm": true, "checkVariableNames": false, "unitTests": [], "showPreview": true, "type": "jme", "scripts": {}, "checkingAccuracy": 0.001, "showCorrectAnswer": true, "showFeedbackIcon": true}, {"answer": "{B}", "useCustomName": false, "customMarkingAlgorithm": "", "marks": 1, "variableReplacements": [], "vsetRangePoints": 5, "customName": "", "vsetRange": [0, 1], "prompt": "

What is the subset that contains exactly two elements?

", "variableReplacementStrategy": "originalfirst", "failureRate": 1, "checkingType": "absdiff", "adaptiveMarkingPenalty": 0, "valuegenerators": [], "extendBaseMarkingAlgorithm": true, "checkVariableNames": true, "unitTests": [], "showPreview": true, "type": "jme", "scripts": {}, "checkingAccuracy": 0.001, "showCorrectAnswer": true, "showFeedbackIcon": true}, {"prompt": "

The power set is the set containg all these answers as elements. Enter your answer using the NUMBAS syntax set(a,b,c,d) where $a,b,c$ and $d$ are your answers above.

", "useCustomName": false, "customMarkingAlgorithm": "", "marks": 0, "variableReplacements": [], "unitTests": [], "customName": "", "scripts": {}, "variableReplacementStrategy": "originalfirst", "type": "information", "showFeedbackIcon": true, "extendBaseMarkingAlgorithm": true, "showCorrectAnswer": true, "adaptiveMarkingPenalty": 0}], "adaptiveMarkingPenalty": 0, "valuegenerators": [], "extendBaseMarkingAlgorithm": true, "checkVariableNames": true, "unitTests": [], "showPreview": true, "stepsPenalty": 0, "type": "jme", "scripts": {"mark": {"script": "\n\nvar variables = this.question.scope.variables;\nvar unwrap = Numbas.jme.unwrapValue;\nvar b1 = unwrap(variables.b1);\nvar b2 = unwrap(variables.b2);\n\nfunction setToStr(setofthings) {\n var s = \"$\\\\left\\\\{\";\n \n for (var i = 0; i < setofthings.length; i++)\n {\n s += setofthings[i].value;\n if (i < setofthings.length - 1)\n s += \",\";\n }\n \n return s + \"\\\\right\\\\}$\";\n}\n\nvar b_expression = \"set(set(),set(\" + b1 + \"), set(\" +b2 + \"), set(\"+b1+\",\"+b2+\"))\";\nvar tree;\ntry {\n tree = Numbas.jme.compile(this.studentAnswer + \"- set()\");\n var ans = unwrap(Numbas.jme.evaluate(tree,this.question.scope));\n \n // check answer has correct length\n if (ans.length != 4)\n {\n this.setCredit(0,\"Your answer should be a set of $4$ elements\");\n return;\n }\n \n \n // look for elements of the answer that are not in b\n tree = Numbas.jme.compile(this.studentAnswer + \" - \" + b_expression);\n var ans_b = unwrap(Numbas.jme.evaluate(tree,this.question.scope));\n for (var i = 0; i < ans_b.length; i++)\n {\n if (\"set\" != ans_b[i].type)\n this.setCredit(0, \"$\" + ans[i].value + \"$ is not a subset of $\\\\left\\\\{\" + b1 + \",\" + b2 + \"\\\\right\\\\}$.\");\n \n else\n this.setCredit(0, setToStr(ans_b[i].value) + \" is not a subset of $\\\\left\\\\{\" + b1 + \",\" + b2 + \"\\\\right\\\\}$.\");\n }\n \n tree = Numbas.jme.compile(b_expression + \" - \" + this.studentAnswer);\n var b_ans = unwrap(Numbas.jme.evaluate(tree,this.question.scope));\n for (var i = 0; i < ans_b.length; i++)\n {\n this.setCredit(0, setToStr(b_ans[i].value) + \" is a subset of $\\\\left\\\\{\" + b1 + \",\" + b2 + \"\\\\right\\\\}$ but it is not in your answer.\");\n }\n \n if (0 == ans_b.length && 0 == b_ans.length) \n {\n this.setCredit(1, \"This is the power set.\");\n }\n \n}\ncatch(e) {\n this.markingComment(e);\n}", "order": "instead"}}, "checkingAccuracy": 0.001, "showCorrectAnswer": true, "showFeedbackIcon": true}], "statement": "

The power set of $A$, written $P(A)$, is the set of all subsets of $A$.

", "variables": {"listB": {"name": "listB", "description": "", "templateType": "anything", "definition": "[b1,b2]", "group": "Ungrouped variables"}, "b1": {"name": "b1", "description": "", "templateType": "anything", "definition": "random(0..9)", "group": "Ungrouped variables"}, "B": {"name": "B", "description": "", "templateType": "anything", "definition": "set(listB)", "group": "Ungrouped variables"}, "b2": {"name": "b2", "description": "", "templateType": "anything", "definition": "random(0..9 except b1)", "group": "Ungrouped variables"}, "PB": {"name": "PB", "description": "", "templateType": "anything", "definition": "set(set(),set(listB[0]),set(listB[1]),B)", "group": "Ungrouped variables"}}, "variablesTest": {"condition": "", "maxRuns": 100}, "metadata": {"description": "

Introductory exercise about power sets.

", "licence": "Creative Commons Attribution-ShareAlike 4.0 International"}, "ungrouped_variables": ["listB", "PB", "B", "b1", "b2"], "advice": "

The power set of $\\left\\{\\var{listB[0]},\\var{listB[1]}\\right\\}$ is

\n

$\\left\\{\\left\\{\\right\\}, \\left\\{\\var{listB[0]}\\right\\},\\left\\{\\var{listB[1]}\\right\\}, \\left\\{\\var{listB[0]},\\var{listB[1]}\\right\\}\\right\\}$.

\n

You can obtain the power set by finding all the subsets of all possible sizes. Since we have a set of size two then the subsets have length at most two. These are

\n\n

Note that the length zero subset is always the empty set, and the largest subset is the set itself.

", "extensions": [], "functions": {}, "name": "Basic Set Theory: power set", "variable_groups": [], "tags": [], "contributors": [{"name": "Daniel Mansfield", "profile_url": "https://numbas.mathcentre.ac.uk/accounts/profile/743/"}, {"name": "Sean Gardiner", "profile_url": "https://numbas.mathcentre.ac.uk/accounts/profile/2443/"}]}]}], "contributors": [{"name": "Daniel Mansfield", "profile_url": "https://numbas.mathcentre.ac.uk/accounts/profile/743/"}, {"name": "Sean Gardiner", "profile_url": "https://numbas.mathcentre.ac.uk/accounts/profile/2443/"}]}