// Numbas version: exam_results_page_options {"name": "Sampling, Combinations and Permutations", "metadata": {"description": "", "licence": "Creative Commons Attribution-ShareAlike 4.0 International"}, "duration": 0, "percentPass": 0, "showQuestionGroupNames": false, "showstudentname": true, "question_groups": [{"name": "Discrete Mathematics", "pickingStrategy": "all-ordered", "pickQuestions": 1, "questionNames": ["", ""], "questions": [{"name": "Counting: permutation and combination", "extensions": [], "custom_part_types": [], "resources": [], "navigation": {"allowregen": true, "showfrontpage": false, "preventleave": false, "typeendtoleave": false}, "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/"}, {"name": "Stephen Maher", "profile_url": "https://numbas.mathcentre.ac.uk/accounts/profile/9339/"}], "tags": [], "metadata": {"description": "

Introduction to counting with permutations and combinations

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

How many ways can you choose $r$ distinct objects from $n$ possible objects?

\n

The answer depends upon whether the order of selection is important.

\n\n

The NUMBAS syntax for $P(n,r)$ and $C(n,r)$ is perm(n,r) and comb(n,r).

", "advice": "

For part a, choosing $\\var{r}$ from $\\var{n}$ distinct objects when order matters can be done in $P(\\var{n},\\var{r}) = \\var{perm(n,r)}$ ways.

\n

For part b, choosing $\\var{r2}$ from $\\var{n}$ distinct objects when order does not matter can be done in $C(\\var{n},\\var{r2}) = \\var{comb(n,r2)}$ ways.

", "rulesets": {}, "variables": {"r2": {"name": "r2", "group": "Ungrouped variables", "definition": "r", "description": "", "templateType": "anything"}, "a2": {"name": "a2", "group": "Ungrouped variables", "definition": "random(1..9 except a1)", "description": "", "templateType": "anything"}, "a1": {"name": "a1", "group": "Ungrouped variables", "definition": "random(1..9)", "description": "", "templateType": "anything"}, "n": {"name": "n", "group": "Ungrouped variables", "definition": "random(5..9)", "description": "", "templateType": "anything"}, "a3": {"name": "a3", "group": "Ungrouped variables", "definition": "random(1..9 except [a1,a2])", "description": "", "templateType": "anything"}, "r": {"name": "r", "group": "Ungrouped variables", "definition": "random(2..(n-1))", "description": "", "templateType": "anything"}}, "variablesTest": {"condition": "", "maxRuns": 100}, "ungrouped_variables": ["a1", "a2", "a3", "n", "r", "r2"], "variable_groups": [], "functions": {}, "preamble": {"js": "", "css": ""}, "parts": [{"type": "jme", "useCustomName": false, "customName": "", "marks": "1", "showCorrectAnswer": true, "showFeedbackIcon": true, "scripts": {}, "variableReplacements": [], "variableReplacementStrategy": "originalfirst", "adaptiveMarkingPenalty": 0, "customMarkingAlgorithm": "", "extendBaseMarkingAlgorithm": true, "unitTests": [], "prompt": "

You have $\\var{n}$ disctinct Discrete Mathematics textbooks, but you can only display $\\var{r}$ in a row on your bookshelf. How many ways can you arrange your Discrete Mathematics textbooks?

", "stepsPenalty": 0, "steps": [{"type": "1_n_2", "useCustomName": false, "customName": "", "marks": 0, "showCorrectAnswer": true, "showFeedbackIcon": true, "scripts": {}, "variableReplacements": [], "variableReplacementStrategy": "originalfirst", "adaptiveMarkingPenalty": 0, "customMarkingAlgorithm": "", "extendBaseMarkingAlgorithm": true, "unitTests": [], "prompt": "

Does the order of books on your bookshelf matter?

", "minMarks": 0, "maxMarks": 0, "shuffleChoices": false, "displayType": "radiogroup", "displayColumns": 0, "showCellAnswerState": true, "choices": ["

Yes

", "

No

"], "matrix": ["0.5", 0], "distractors": ["Good, you have a well-ordered shelf.", "No, go home and arrange your books properly."]}, {"type": "information", "useCustomName": false, "customName": "", "marks": 0, "showCorrectAnswer": true, "showFeedbackIcon": true, "scripts": {}, "variableReplacements": [], "variableReplacementStrategy": "originalfirst", "adaptiveMarkingPenalty": 0, "customMarkingAlgorithm": "", "extendBaseMarkingAlgorithm": true, "unitTests": [], "prompt": "

If order matters, then the answer is $P(\\var{n},\\var{r})$. 

\n

If the order does not matter, then the answer is $C(\\var{n},\\var{r})$.

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

You want to keep your valuable Discrete Mathematics textbooks close at all times. But it's time for class and you only have room for $\\var{r2}$ Discrete Mathematics books in your backpack. How many ways can you pack your backpack?

", "stepsPenalty": 0, "steps": [{"type": "1_n_2", "useCustomName": false, "customName": "", "marks": 0, "showCorrectAnswer": true, "showFeedbackIcon": true, "scripts": {}, "variableReplacements": [], "variableReplacementStrategy": "originalfirst", "adaptiveMarkingPenalty": 0, "customMarkingAlgorithm": "", "extendBaseMarkingAlgorithm": true, "unitTests": [], "prompt": "

Does the order in which you place books into your backpack change which books you take to UNSW?

", "minMarks": 0, "maxMarks": 0, "shuffleChoices": false, "displayType": "radiogroup", "displayColumns": 0, "showCellAnswerState": true, "choices": ["

Yes

", "

No

"], "matrix": [0, "0.5"], "distractors": ["Perhaps you should get a better backpack.", "The order does not matter in this scenario."]}, {"type": "information", "useCustomName": false, "customName": "", "marks": 0, "showCorrectAnswer": true, "showFeedbackIcon": true, "scripts": {}, "variableReplacements": [], "variableReplacementStrategy": "originalfirst", "adaptiveMarkingPenalty": 0, "customMarkingAlgorithm": "", "extendBaseMarkingAlgorithm": true, "unitTests": [], "prompt": "

If order matters, then the answer is $P(\\var{n},\\var{r2})$. 

\n

If the order does not matter, then the answer is $C(\\var{n},\\var{r2})$.

"}], "answer": "{comb(n,r2)}", "showPreview": true, "checkingType": "absdiff", "checkingAccuracy": 0.001, "failureRate": 1, "vsetRangePoints": 5, "vsetRange": [0, 1], "checkVariableNames": false, "valuegenerators": []}]}, {"name": "Counting: string enumeration", "extensions": [], "custom_part_types": [], "resources": [], "navigation": {"allowregen": true, "showfrontpage": false, "preventleave": false, "typeendtoleave": false}, "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/"}, {"name": "Stephen Maher", "profile_url": "https://numbas.mathcentre.ac.uk/accounts/profile/9339/"}], "tags": [], "metadata": {"description": "

Simple counting exercise, with combinations

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

A randomised string of $\\var{n}$ digits is made using only the non-zero digits $1,2,3,4,5,6,7,8,9$.

\n

When each digit is chosen independently, the number of ways to choose the string is just the product of the number of ways to choose each of the digits.

\n

# of ways to choose string = $\\displaystyle \\prod\\limits_{i=1}^{\\var{n}}$ (# ways to choose $i$th digit).

", "advice": "

(a) # of ways to choose string $=$ $\\displaystyle \\prod\\limits_{i=1}^{\\var{n}}$ (# ways to choose $i$th digit) $=$ $\\displaystyle \\prod\\limits_{i=1}^{\\var{n}} 9 =  {9^\\var{n} }$.

\n

(b) # of ways to choose string $=$ (# of ways of choosing an even digit) $\\times$ (# of ways of choosing an odd digit) $\\times \\displaystyle \\prod\\limits_{i=3}^{\\var{n}}$ (# ways to choose a digit less than $\\var{b}$) $=$ $4 \\times 5 \\times {\\var{b-1}^\\var{n-2}}$.

\n

(c) # of ways to choose string $=$ (# of ways of placing the 9s) $\\times$ (# of ways of placing the remaining digits) $=$ ${C(\\var{n},\\var{c})}\\times 8^\\var{n-c}$.

", "rulesets": {}, "variables": {"b": {"name": "b", "group": "Ungrouped variables", "definition": "random(4..8)", "description": "", "templateType": "anything"}, "ex2": {"name": "ex2", "group": "Ungrouped variables", "definition": "sum(map(random(1..9)*10^k,k,0..(n-1)))", "description": "", "templateType": "anything"}, "c": {"name": "c", "group": "Ungrouped variables", "definition": "random(2..(n-1))", "description": "", "templateType": "anything"}, "n": {"name": "n", "group": "Ungrouped variables", "definition": "random(4..8)", "description": "", "templateType": "anything"}, "ex1": {"name": "ex1", "group": "Ungrouped variables", "definition": "sum(map(random(1..9)*10^k,k,0..(n-1)))", "description": "", "templateType": "anything"}}, "variablesTest": {"condition": "not(ex1 = ex2)", "maxRuns": 100}, "ungrouped_variables": ["ex1", "ex2", "n", "b", "c"], "variable_groups": [], "functions": {}, "preamble": {"js": "", "css": ""}, "parts": [{"type": "jme", "useCustomName": false, "customName": "", "marks": "1", "showCorrectAnswer": true, "showFeedbackIcon": true, "scripts": {}, "variableReplacements": [], "variableReplacementStrategy": "originalfirst", "adaptiveMarkingPenalty": 0, "customMarkingAlgorithm": "", "extendBaseMarkingAlgorithm": true, "unitTests": [], "prompt": "

Assuming there are no other restrictions, how many strings are possible?

", "stepsPenalty": 0, "steps": [{"type": "numberentry", "useCustomName": false, "customName": "", "marks": "0.25", "showCorrectAnswer": true, "showFeedbackIcon": true, "scripts": {}, "variableReplacements": [], "variableReplacementStrategy": "originalfirst", "adaptiveMarkingPenalty": 0, "customMarkingAlgorithm": "", "extendBaseMarkingAlgorithm": true, "unitTests": [], "prompt": "

It might be helpful to first consider some examples. The chosen string could be

\n

$\\var{ex1}$ or $\\var{ex2}$.

\n

How many ways can you choose the first digit?

", "minValue": "9", "maxValue": "9", "correctAnswerFraction": false, "allowFractions": false, "mustBeReduced": false, "mustBeReducedPC": 0, "showFractionHint": true, "notationStyles": ["plain", "en", "si-en"], "correctAnswerStyle": "plain"}, {"type": "numberentry", "useCustomName": false, "customName": "", "marks": "0.25", "showCorrectAnswer": true, "showFeedbackIcon": true, "scripts": {}, "variableReplacements": [], "variableReplacementStrategy": "originalfirst", "adaptiveMarkingPenalty": 0, "customMarkingAlgorithm": "", "extendBaseMarkingAlgorithm": true, "unitTests": [], "prompt": "

How many ways can you choose the $\\var{n}$th digit?

", "minValue": "9", "maxValue": "9", "correctAnswerFraction": false, "allowFractions": false, "mustBeReduced": false, "mustBeReducedPC": 0, "showFractionHint": true, "notationStyles": ["plain", "en", "si-en"], "correctAnswerStyle": "plain"}], "answer": "{9^n}", "showPreview": true, "checkingType": "absdiff", "checkingAccuracy": 0.001, "failureRate": 1, "vsetRangePoints": 5, "vsetRange": [0, 1], "checkVariableNames": false, "valuegenerators": []}, {"type": "jme", "useCustomName": false, "customName": "", "marks": "1", "showCorrectAnswer": true, "showFeedbackIcon": true, "scripts": {}, "variableReplacements": [], "variableReplacementStrategy": "originalfirst", "adaptiveMarkingPenalty": 0, "customMarkingAlgorithm": "", "extendBaseMarkingAlgorithm": true, "unitTests": [], "prompt": "

How many strings are possible if the first digit must be even, the second digit odd, and the remaining $\\var{n-2}$ digits are less than $\\var{b}$?

", "stepsPenalty": 0, "steps": [{"type": "numberentry", "useCustomName": false, "customName": "", "marks": "0.25", "showCorrectAnswer": true, "showFeedbackIcon": true, "scripts": {}, "variableReplacements": [], "variableReplacementStrategy": "originalfirst", "adaptiveMarkingPenalty": 0, "customMarkingAlgorithm": "", "extendBaseMarkingAlgorithm": true, "unitTests": [], "prompt": "

How many ways can an even number be chosen for the first digit?

", "minValue": "4", "maxValue": "4", "correctAnswerFraction": false, "allowFractions": false, "mustBeReduced": false, "mustBeReducedPC": 0, "showFractionHint": true, "notationStyles": ["plain", "en", "si-en"], "correctAnswerStyle": "plain"}, {"type": "numberentry", "useCustomName": false, "customName": "", "marks": "0.25", "showCorrectAnswer": true, "showFeedbackIcon": true, "scripts": {}, "variableReplacements": [], "variableReplacementStrategy": "originalfirst", "adaptiveMarkingPenalty": 0, "customMarkingAlgorithm": "", "extendBaseMarkingAlgorithm": true, "unitTests": [], "prompt": "

How many ways can an odd number be chosen for the second digit?

", "minValue": "5", "maxValue": "5", "correctAnswerFraction": false, "allowFractions": false, "mustBeReduced": false, "mustBeReducedPC": 0, "showFractionHint": true, "notationStyles": ["plain", "en", "si-en"], "correctAnswerStyle": "plain"}, {"type": "jme", "useCustomName": false, "customName": "", "marks": "0.25", "showCorrectAnswer": true, "showFeedbackIcon": true, "scripts": {}, "variableReplacements": [], "variableReplacementStrategy": "originalfirst", "adaptiveMarkingPenalty": 0, "customMarkingAlgorithm": "", "extendBaseMarkingAlgorithm": true, "unitTests": [], "prompt": "

How many ways can the remaining $\\var{n-2}$ digits be chosen, given that they must each be less than $\\var{b}$?

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

How many strings are possible which contain exactly $\\var{c}$ nines?

", "stepsPenalty": 0, "steps": [{"type": "jme", "useCustomName": false, "customName": "", "marks": "0.25", "showCorrectAnswer": true, "showFeedbackIcon": true, "scripts": {}, "variableReplacements": [], "variableReplacementStrategy": "originalfirst", "adaptiveMarkingPenalty": 0, "customMarkingAlgorithm": "", "extendBaseMarkingAlgorithm": true, "unitTests": [], "prompt": "

Note that each digit is no longer independently chosen. But we can split the question into two independent parts.

\n

First, count the number of ways to choose positions for each of the $\\var{c}$ nines. Since the order of the positions does not matter (all the nines look identical), this is a combination. Remember you can use the NUMBAS command comb(n,r) for $C(n,r)$.

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

Then, count the number of ways to choose the digits for the rest of the string. Remember, you can't use the digit nine anymore, so there are 8 choices for each of the remaining unfilled positions. 

", "answer": "{8^(n-c)}", "showPreview": true, "checkingType": "absdiff", "checkingAccuracy": 0.001, "failureRate": 1, "vsetRangePoints": 5, "vsetRange": [0, 1], "checkVariableNames": false, "valuegenerators": []}], "answer": "{comb(n,c)*8^(n-c)}", "showPreview": true, "checkingType": "absdiff", "checkingAccuracy": 0.001, "failureRate": 1, "vsetRangePoints": 5, "vsetRange": [0, 1], "checkVariableNames": false, "valuegenerators": []}]}]}], "allowPrinting": true, "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": "Stephen Maher", "profile_url": "https://numbas.mathcentre.ac.uk/accounts/profile/9339/"}], "extensions": [], "custom_part_types": [], "resources": []}