// Numbas version: exam_results_page_options {"name": "string enumeration", "extensions": [], "custom_part_types": [], "resources": [], "navigation": {"allowregen": true, "showfrontpage": false, "preventleave": false, "typeendtoleave": false}, "question_groups": [{"pickingStrategy": "all-ordered", "questions": [{"name": "string enumeration", "metadata": {"licence": "Creative Commons Attribution-ShareAlike 4.0 International", "description": "

Simple counting exercise, with combinations

"}, "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}$.

", "extensions": [], "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).

", "variable_groups": [], "preamble": {"css": "", "js": ""}, "variables": {"ex2": {"name": "ex2", "templateType": "anything", "group": "Ungrouped variables", "description": "", "definition": "sum(map(random(1..9)*10^k,k,0..(n-1)))"}, "b": {"name": "b", "templateType": "anything", "group": "Ungrouped variables", "description": "", "definition": "random(4..8)"}, "c": {"name": "c", "templateType": "anything", "group": "Ungrouped variables", "description": "", "definition": "random(2..(n-1))"}, "n": {"name": "n", "templateType": "anything", "group": "Ungrouped variables", "description": "", "definition": "random(4..8)"}, "ex1": {"name": "ex1", "templateType": "anything", "group": "Ungrouped variables", "description": "", "definition": "sum(map(random(1..9)*10^k,k,0..(n-1)))"}}, "tags": [], "parts": [{"variableReplacements": [], "stepsPenalty": 0, "variableReplacementStrategy": "originalfirst", "checkVariableNames": false, "unitTests": [], "showPreview": true, "answer": "{9^n}", "showCorrectAnswer": true, "scripts": {}, "vsetRange": [0, 1], "marks": "2", "vsetRangePoints": 5, "valuegenerators": [], "type": "jme", "useCustomName": false, "failureRate": 1, "steps": [{"variableReplacements": [], "minValue": "9", "maxValue": "9", "showCorrectAnswer": true, "showFractionHint": true, "correctAnswerFraction": false, "mustBeReducedPC": 0, "notationStyles": ["plain", "en", "si-en"], "unitTests": [], "scripts": {}, "extendBaseMarkingAlgorithm": true, "marks": "0.5", "type": "numberentry", "useCustomName": false, "mustBeReduced": false, "correctAnswerStyle": "plain", "customName": "", "variableReplacementStrategy": "originalfirst", "showFeedbackIcon": true, "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?

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

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

", "allowFractions": false, "customMarkingAlgorithm": ""}], "customName": "", "checkingAccuracy": 0.001, "showFeedbackIcon": true, "prompt": "

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

", "extendBaseMarkingAlgorithm": true, "checkingType": "absdiff", "customMarkingAlgorithm": ""}, {"variableReplacements": [], "stepsPenalty": 0, "variableReplacementStrategy": "originalfirst", "checkVariableNames": false, "unitTests": [], "showPreview": true, "answer": "{(b-1)^(n-2)*4*5}", "showCorrectAnswer": true, "scripts": {}, "vsetRange": [0, 1], "marks": "2", "vsetRangePoints": 5, "valuegenerators": [], "type": "jme", "useCustomName": false, "failureRate": 1, "steps": [{"variableReplacements": [], "minValue": "4", "maxValue": "4", "showCorrectAnswer": true, "showFractionHint": true, "correctAnswerFraction": false, "mustBeReducedPC": 0, "notationStyles": ["plain", "en", "si-en"], "unitTests": [], "scripts": {}, "extendBaseMarkingAlgorithm": true, "marks": "0.5", "type": "numberentry", "useCustomName": false, "mustBeReduced": false, "correctAnswerStyle": "plain", "customName": "", "variableReplacementStrategy": "originalfirst", "showFeedbackIcon": true, "prompt": "

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

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

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

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

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

", "checkingType": "absdiff", "customMarkingAlgorithm": ""}], "customName": "", "checkingAccuracy": 0.001, "showFeedbackIcon": true, "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}$?

", "extendBaseMarkingAlgorithm": true, "checkingType": "absdiff", "customMarkingAlgorithm": ""}, {"variableReplacements": [], "stepsPenalty": 0, "variableReplacementStrategy": "originalfirst", "checkVariableNames": false, "unitTests": [], "showPreview": true, "answer": "{comb(n,c)*8^(n-c)}", "showCorrectAnswer": true, "scripts": {}, "vsetRange": [0, 1], "marks": "2", "vsetRangePoints": 5, "valuegenerators": [], "type": "jme", "useCustomName": false, "failureRate": 1, "steps": [{"variableReplacements": [], "vsetRange": [0, 1], "checkVariableNames": false, "unitTests": [], "showPreview": true, "answer": "{comb(n,c)}", "showCorrectAnswer": true, "scripts": {}, "extendBaseMarkingAlgorithm": true, "marks": "0.5", "vsetRangePoints": 5, "valuegenerators": [], "type": "jme", "useCustomName": false, "failureRate": 1, "checkingAccuracy": 0.001, "customName": "", "variableReplacementStrategy": "originalfirst", "showFeedbackIcon": true, "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)$.

", "checkingType": "absdiff", "customMarkingAlgorithm": ""}, {"variableReplacements": [], "vsetRange": [0, 1], "checkVariableNames": false, "unitTests": [], "showPreview": true, "answer": "{8^(n-c)}", "showCorrectAnswer": true, "scripts": {}, "extendBaseMarkingAlgorithm": true, "marks": "0.5", "vsetRangePoints": 5, "valuegenerators": [], "type": "jme", "useCustomName": false, "failureRate": 1, "checkingAccuracy": 0.001, "customName": "", "variableReplacementStrategy": "originalfirst", "showFeedbackIcon": true, "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. 

", "checkingType": "absdiff", "customMarkingAlgorithm": ""}], "customName": "", "checkingAccuracy": 0.001, "showFeedbackIcon": true, "prompt": "

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

", "extendBaseMarkingAlgorithm": true, "checkingType": "absdiff", "customMarkingAlgorithm": ""}], "variablesTest": {"condition": "not(ex1 = ex2)", "maxRuns": 100}, "ungrouped_variables": ["ex1", "ex2", "n", "b", "c"], "rulesets": {}, "functions": {}, "contributors": [{"name": "Daniel Mansfield", "profile_url": "https://numbas.mathcentre.ac.uk/accounts/profile/743/"}, {"name": "Xiaodan Leng", "profile_url": "https://numbas.mathcentre.ac.uk/accounts/profile/2146/"}, {"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": "Xiaodan Leng", "profile_url": "https://numbas.mathcentre.ac.uk/accounts/profile/2146/"}, {"name": "Sean Gardiner", "profile_url": "https://numbas.mathcentre.ac.uk/accounts/profile/2443/"}]}