You are told that a triangle has {first_given} side {sides[first_given]}m, and {second_given} side {sides[second_given]}m.

", "ungrouped_variables": ["opposite", "adjacent", "hypotenuse", "sides", "missing", "first_given", "second_given", "signs"], "parts": [{"scripts": {}, "variableReplacements": [], "prompt": "What is the length of the {missing}?

\n[[0]]m

", "type": "gapfill", "marks": 0, "showFeedbackIcon": true, "gaps": [{"showCorrectAnswer": true, "type": "numberentry", "marks": 1, "maxValue": "sides[missing]", "notationStyles": ["plain", "en", "si-en"], "variableReplacementStrategy": "originalfirst", "allowFractions": false, "scripts": {}, "variableReplacements": [], "mustBeReducedPC": 0, "showFeedbackIcon": true, "correctAnswerFraction": false, "mustBeReduced": false, "minValue": "sides[missing]", "correctAnswerStyle": "plain"}], "showCorrectAnswer": true, "variableReplacementStrategy": "originalfirst"}], "type": "question", "variable_groups": [], "rulesets": {}, "name": "Lovkush's copy of Randomly give two of hypotenuse, opposite, and adjacent side of a triangle", "advice": "We are given the {first_given} and the {second_given}.

\nWe can use Pythagoras' theorem to work out the {missing}.

\nPythagoras' theorem states that

\n\\[ a^2 + b^2 = c^2 \\text{,} \\]

\nwhere $a$ is the opposite side, $b$ is the adjacent side, and $c$ is the hypotenuse.

\nSubstituting the values into this equation, we have

\n\\[ \\var{opposite}^2 + \\var{adjacent}^2 = c^2 \\]\\[ \\var{opposite}^2 + b^2 = \\var{hypotenuse}^2 \\]\\[ a^2 + \\var{adjacent}^2 = \\var{hypotenuse}^2 \\]

\nSo the {missing} is

\n\\[ \\simplify[noleadingminus,unitfactor]{ sqrt({signs[second_given]}*{sides[first_given]}^2 + {sides[second_given]}^2)} = \\sqrt{\\var{sides[missing]^2}} = \\var{sides[missing]}\\text{m} \\]

", "variablesTest": {"maxRuns": 100, "condition": ""}, "extensions": [], "variables": {"sides": {"definition": "[\"opposite side\":opposite,\"adjacent side\":adjacent,\"hypotenuse\":hypotenuse]", "description": "A dictionary giving the lengths of the sides. Used in the statement and to set the correct answer.

", "name": "sides", "templateType": "anything", "group": "Ungrouped variables"}, "adjacent": {"definition": "(opposite^2-1)/2", "description": "The length of the adjacent side. The sides will always form a Pythagorean triple.

", "name": "adjacent", "templateType": "anything", "group": "Ungrouped variables"}, "hypotenuse": {"definition": "adjacent+1", "description": "The length of the hypotenuse.

", "name": "hypotenuse", "templateType": "anything", "group": "Ungrouped variables"}, "signs": {"definition": "[\"opposite side\": 1, \"adjacent side\": 1, \"hypotenuse\": -1]", "description": "Signs of each of the components in the equation $a^2 + b^2 - c^2 = 0$. Used in the working-out in the advice.

\nIn the equation $\\text{missing} = \\sqrt{ \\pm \\text{first}^2 \\pm \\text{second}^2}$, note that:

\n- \n
- when the hypotenuse is missing, both sides in the square root are positive: $\\sqrt{ \\text{first}^2 + \\text{second}^2} = \\sqrt{a^2+b^2}$ \n
- when either of the other sides is missing, it's $\\sqrt{- \\text{first}^2 + \\text{second}^2} = \\sqrt{-(a \\text{ or } b)^2 + c^2}$. \n

So, only the first side in the square root changes sign depending on the missing side.

", "name": "signs", "templateType": "anything", "group": "Ungrouped variables"}, "missing": {"definition": "random(keys(sides))", "description": "The name of the side which the student has to work out.

", "name": "missing", "templateType": "anything", "group": "Ungrouped variables"}, "first_given": {"definition": "if(missing=\"opposite side\",\"adjacent side\",\"opposite side\")", "description": "The name of the first side given to the student.

", "name": "first_given", "templateType": "anything", "group": "Ungrouped variables"}, "second_given": {"definition": "if(missing=\"hypotenuse\",\"adjacent side\",\"hypotenuse\")", "description": "The name of the second side given to the student.

", "name": "second_given", "templateType": "anything", "group": "Ungrouped variables"}, "opposite": {"definition": "random(3..13#2)", "description": "The length of the opposite side.

", "name": "opposite", "templateType": "anything", "group": "Ungrouped variables"}}, "tags": [], "preamble": {"css": "", "js": ""}, "metadata": {"description": "Some clever variable-substitution trickery to randomly pick two sides of a right-angled triangle to give to a student, and ask for the other.

\nThe sides are set up so they're always Pythagorean triples, and the opposite side is always odd.

\nAs ever, most of the tricky stuff is in the advice.

\nBecause this was created quickly to show how to set up the randomisation, there's no diagram. It would benefit greatly from a diagram.

", "licence": "Creative Commons Attribution 4.0 International"}, "functions": {}, "contributors": [{"profile_url": "https://numbas.mathcentre.ac.uk/accounts/profile/1358/", "name": "Lovkush Agarwal"}]}], "pickingStrategy": "all-ordered"}], "contributors": [{"profile_url": "https://numbas.mathcentre.ac.uk/accounts/profile/1358/", "name": "Lovkush Agarwal"}]}