// Numbas version: exam_results_page_options {"name": "Ben's copy of Subtraction", "extensions": [], "custom_part_types": [], "resources": [], "navigation": {"allowregen": true, "showfrontpage": false, "preventleave": false, "typeendtoleave": false}, "question_groups": [{"pickingStrategy": "all-ordered", "questions": [{"rulesets": {}, "tags": [], "extensions": [], "statement": "

Write the following question down on paper and evaluate it without using a calculator.

\n

If you are unsure of how to do a question, click on Show steps to see the full working. Then, once you understand how to do the question, click on Try another question like this one to start again.

", "parts": [{"steps": [{"unitTests": [], "prompt": "

Generally we set up $\\var{topnum}-\\var{botnum}$ with the ones, tens and hundreds columns lined up vertically:

\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n
$\\var{top[2]}$$\\var{top[1]}$$\\var{top[0]}$$-$
$\\var{bot[2]}$$\\var{bot[1]}$$\\var{bot[0]}$
$\\phantom{0}$
\n

\n

Now we try to subtract the digits in the ones column.

\n

Since this is $\\var{ansunit}$ we write $\\var{ansunit}$ under the line in the ones column.

\n

Since we can't take $\\var{bot[0]}$ away from $\\var{top[0]}$ (without using negative numbers) we borrow a ten from the tens column. This means we cross out the $\\var{top[1]}$ in the tens column and replace it with a $\\var{top[1]-1}$, and the $\\var{top[0]}$ becomes a $\\var{10+top[0]}$. Now we can do $\\var{10+top[0]}-\\var{bot[0]}$, and write the result, $\\var{ansunit}$, under the line in the ones column. 

\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n
$\\overset{\\phantom{1}}{\\var{top[2]}}$$\\overset{\\color{red}{\\var{newtopten}}}{\\var{top[1]}\\mkern-7.5mu\\color{red}/}$ $\\overset{\\phantom{1}}{\\var{top[1]}}$$\\color{red}{^1}\\overset{\\phantom{1}}{\\var{top[0]}}$ $\\overset{\\phantom{1}}{\\var{top[0]}}$$-$
$\\var{bot[2]}$$\\var{bot[1]}$$\\var{bot[0]}$
$\\color{red}{\\var{ansunit}}$
\n

\n

Now we try to subtract the digits in the tens column.

\n

Since this is $\\var{ansten}$ we write $\\var{ansten}$ under the line in the tens column.

\n

Since we can't take $\\var{bot[1]}$ away from $\\var{newtopten}$ (without using negative numbers) we borrow a hundred from the hundred column. This means we cross out the $\\var{top[2]}$ in the hundreds column and replace it with a $\\var{top[2]-1}$, and the $\\var{newtopten}$ in the tens column becomes a $\\var{10+newtopten}$. Now we can do $\\var{10+newtopten}-\\var{bot[1]}$, and write the result, $\\var{ansten}$, under the line in the tens column. 

\n

\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n
\n

$\\overset{\\color{red}{\\var{newtophun}}}{\\var{top[2]}\\mkern-7.5mu\\color{red}{/}}$ $\\overset{\\phantom{1}}{\\var{top[2]}}$

\n
\n

$\\overset{\\color{red}{1}\\var{newtopten}}{\\var{top[1]}\\mkern-7.5mu/}$ $\\overset{\\var{newtopten}}{\\var{top[1]}\\mkern-7.5mu/}$ $\\color{red}{^1}\\overset{\\phantom{1}}{\\var{top[1]}}$ $\\overset{\\phantom{1}}{\\var{top[1]}}$

\n
${^1}\\overset{\\phantom{1}}{\\var{top[0]}}$ $\\overset{\\phantom{1}}{\\var{top[0]}}$$-$
$\\var{bot[2]}$$\\var{bot[1]}$$\\var{bot[0]}$
$\\color{red}{\\var{ansten}}$$\\var{ansunit}$
\n

\n

Now we try to subtract the digits in the hundreds column.

\n

\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n
\n

$\\overset{\\var{newtophun}}{\\var{top[2]}\\mkern-7.5mu/}$ $\\overset{\\phantom{1}}{\\var{top[2]}}$

\n
\n

$\\overset{{1}\\var{newtopten}}{\\var{top[1]}\\mkern-7.5mu/}$ $\\overset{\\var{newtopten}}{\\var{top[1]}\\mkern-7.5mu/}$ ${^1}\\overset{\\phantom{1}}{\\var{top[1]}}$ $\\overset{\\phantom{1}}{\\var{top[1]}}$

\n
${^1}\\overset{\\phantom{1}}{\\var{top[0]}}$ $\\overset{\\phantom{1}}{\\var{top[0]}}$$-$
$\\var{bot[2]}$$\\var{bot[1]}$$\\var{bot[0]}$
$\\color{red}{\\var{anshun}}$$\\var{ansten}$$\\var{ansunit}$
\n

\n

The answer is therefore $\\var{ans}$.

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

$\\var{topnum}-\\var{botnum} = $ [[0]]

\n

$\\var{topnum}-\\var{botnum} = $ [[0]]

", "customMarkingAlgorithm": "", "customName": "", "stepsPenalty": "1", "showFeedbackIcon": true, "variableReplacements": [], "type": "gapfill", "sortAnswers": false, "marks": 0, "extendBaseMarkingAlgorithm": true, "useCustomName": false, "gaps": [{"maxValue": "ans", "showFractionHint": true, "unitTests": [], "customMarkingAlgorithm": "", "customName": "", "mustBeReducedPC": 0, "notationStyles": ["plain", "en", "si-en"], "showFeedbackIcon": true, "variableReplacements": [], "allowFractions": false, "mustBeReduced": false, "type": "numberentry", "correctAnswerFraction": false, "correctAnswerStyle": "plain", "marks": 1, "extendBaseMarkingAlgorithm": true, "useCustomName": false, "minValue": "ans", "variableReplacementStrategy": "originalfirst", "scripts": {}, "showCorrectAnswer": true}], "variableReplacementStrategy": "originalfirst", "scripts": {}, "showCorrectAnswer": true}], "advice": "", "functions": {}, "variables": {"bot": {"description": "

This should force some borrowing and paying back, and that the final answer is positive.

", "templateType": "anything", "group": "c", "definition": "random(\nif(top[0]<9,[random(top[0]+1..9), random(top[1]..9), random(1..top[2]-1)],if(top[1]<9,[random(top[0]..9), random(top[1]+1..9), random(1..top[2]-1)]),\"error\"),\nif(top[1]<9,[random(0..top[0]), random(top[1]+1..9), random(1..top[2]-1)],if(top[1]=9,[random(top[0]..9), random(0..9), random(1..top[2]-1)]),\"error\")\n)\n", "name": "bot"}, "botnum": {"description": "", "templateType": "anything", "group": "c", "definition": "bot[0]+bot[1]*10+bot[2]*100", "name": "botnum"}, "tendiff": {"description": "", "templateType": "anything", "group": "c", "definition": "if(unitdiff>=0,top[1]-bot[1],top[1]-1-bot[1])", "name": "tendiff"}, "top": {"description": "

Borrowing from the hundreds to do the units is not covered with this randomisation. We will do that in another part.

", "templateType": "anything", "group": "c", "definition": "random([random(0..9),random(1..8),random(2..9)],[random(0..8),random(1..9),random(2..9)])", "name": "top"}, "ansten": {"description": "", "templateType": "anything", "group": "c", "definition": "mod(floor(ans/10),10)", "name": "ansten"}, "newtophun": {"description": "", "templateType": "anything", "group": "c", "definition": "if(tendiff>=0,top[2],top[2]-1)", "name": "newtophun"}, "ansunit": {"description": "", "templateType": "anything", "group": "c", "definition": "mod(ans,10)", "name": "ansunit"}, "topnum": {"description": "", "templateType": "anything", "group": "c", "definition": "top[0]+top[1]*10+top[2]*100", "name": "topnum"}, "newtopten": {"description": "", "templateType": "anything", "group": "c", "definition": "if(unitdiff>=0,top[1],top[1]-1)", "name": "newtopten"}, "ans": {"description": "", "templateType": "anything", "group": "c", "definition": "topnum-botnum", "name": "ans"}, "unitdiff": {"description": "", "templateType": "anything", "group": "c", "definition": "top[0]-bot[0]", "name": "unitdiff"}, "anshun": {"description": "", "templateType": "anything", "group": "c", "definition": "mod(floor(ans/100),10)", "name": "anshun"}, "hundiff": {"description": "", "templateType": "anything", "group": "c", "definition": "if(tendiff>=0,top[2]-bot[2],top[2]-1-bot[2])", "name": "hundiff"}}, "preamble": {"js": "", "css": ""}, "ungrouped_variables": [], "variablesTest": {"maxRuns": 100, "condition": ""}, "variable_groups": [{"name": "c", "variables": ["top", "bot", "topnum", "botnum", "ans", "tendiff", "hundiff", "ansunit", "ansten", "anshun", "unitdiff", "newtopten", "newtophun"]}], "metadata": {"description": "

The subtraction algortihm using the borrow and pay back method with integers.

", "licence": "Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International"}, "name": "Ben's copy of Subtraction", "type": "question", "contributors": [{"name": "Ben Brawn", "profile_url": "https://numbas.mathcentre.ac.uk/accounts/profile/605/"}, {"name": "Ben George", "profile_url": "https://numbas.mathcentre.ac.uk/accounts/profile/3372/"}]}]}], "contributors": [{"name": "Ben Brawn", "profile_url": "https://numbas.mathcentre.ac.uk/accounts/profile/605/"}, {"name": "Ben George", "profile_url": "https://numbas.mathcentre.ac.uk/accounts/profile/3372/"}]}