← Year 9 Space

Writing a geometry rule as an algorithm

An algorithm is a list of steps with decisions. Write the rule for whether three strips can make a triangle as steps, and mark which are computations and which are decisions.

A cutting machine is given three strip lengths for a triangular frame. How does it know the frame will close?

A cutting machine makes triangular frames from three strips. Before it cuts, a program should check that the three lengths can really make a triangle. The rule from geometry is that the two shorter strips together must be longer than the longest one. An algorithm turns that rule into exact steps: some steps compute a number, and some decide between two paths. Have a guess whether 3, 4 and 8 can make a triangle, and we'll come back to the machine at the end.

How this lesson works: Predict, Try, Investigate, Modify, Practise, Make
PredictRead the problem and decide what you think before you try anything. A wrong guess is fine: it shows you what to look for.

3, 4 and 8

Strips of length 3, 4 and 8 (made up for the task). Can they make a triangle?

TryTry it on the board and compare the result with your prediction.

The sum of the short strips

The strips are 5, 7 and 13. What is the sum of the two shorter strips?

InvestigateWork out why it happens, one step at a time.

Computations and decisions

Worked exampleBefore each step, say what you think comes next.
  1. Read a,b,c\text{Read } a, b, cInput.
Build up to it
Does "Add the other two, S" compute a number or choose a path?

Here is the algorithm: 1. Read the three lengths. 2. Find the longest, L. 3. Add the other two, S. 4. If S is greater than L, say "triangle"; otherwise say "no triangle". Which step is a decision?

Run the algorithm on 5, 6 and 10. What is S, the sum of the two shorter strips?

Lena writes her own algorithm. Test it on 8, 2 and 3. Click the step that makes it fail.

ModifyChange the problem on purpose and see what happens.

Change the algorithm

You want the machine to also say "equilateral" when all three lengths are equal. Where is the best place for that decision?

In a flowchart, which shape holds a decision?

The strips are 4, 4 and 9. What is S minus L? (A negative means it cannot close.)

PractiseA few on your own, to check you have it.

Steps and results

Strips 6, 9 and 14. By how much does S exceed L? (Negative if it falls short.)

Strips 6, 9 and 14: what does the algorithm say?

Review: a shape is enlarged by scale factor 3. How many times bigger is its area?

MakeMake your own problem using what you have learned. Expect a few tries; that is normal.

Check the machine's strips

Write the algorithm in your own words as numbered steps and mark the decision.

Also used in

The machine is asked for strips of 5, 7 and 13. Follow the algorithm and find how many units too short the two shorter strips are (L − S). (The lengths are made up for the task.)

Work it out on paper first, one step per line. Then type your answer.

Now you can
Practise this skillNew questions, new numbers each timeGet 3 right in a row to mark it practised.Next lesson7. Testing an algorithm: where does it fail?Good tests include the boundary and the strange cases, not just easy ones. Test the triangle checker on a set of inputs and find where it gives the wrong answer.
For teachers

An algorithm is a list of steps with decisions. Write the rule for whether three strips can make a triangle as steps, and mark which are computations and which are decisions. About 40 minutes.

Open the teacher guide: answers, solutions, slides and a worksheet.

Students will be able to

Before class

Students need triangles and the Year 7 and 8 classifying algorithms.

The one idea: an algorithm is exact steps, some computing, some deciding. Pseudocode is used here; a flowchart is a drawing of the same steps (a diamond for each decision). Lengths are made up.

Running the lesson

  1. Predict: show of hands before the check.
  2. Make: the working is done on paper first.

The hard part (on purpose)

Writing vague steps like "check the strips". Ask: what exactly does a machine compute, and what does it compare?

When students get stuck

Stretch and support

Stretch: Write the same algorithm as a flowchart, then as pseudocode with a loop that tests a list of strip sets.

Support: A printed copy of the situation and a blank table to fill in.

Where it leads

Starts AC9M9SP03 node 1.

Where it leads: testing with awkward cases (next).

What each step is for