// Numbas version: exam_results_page_options {"name": "Counting 1: string enumeration", "extensions": [], "custom_part_types": [], "resources": [], "navigation": {"allowregen": true, "showfrontpage": false, "preventleave": false, "typeendtoleave": false}, "question_groups": [{"pickingStrategy": "all-ordered", "questions": [{"name": "Counting 1: string enumeration", "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": {}, "extensions": [], "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": []}], "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/"}]}