← Teacher guide

Write the algorithm

Students turn the pinned-down sprinkler job into numbered steps with a decision and a loop, run the steps by hand on two ovals, and find a bug where a sprinkler is placed on the edge of its cell instead of the middle (AC9M10SP03, node 2).

Year 10 Space · Algorithms · about 45 minutes · Open the student lesson

Classroom resources

Open these in Waypoints Prepare with one click. To share a file another way, copy its address and paste it into Load URL, or download the file and import it. In Prepare, the worksheet's Teacher edition shows the answers; the student copy hides them.

Students will be able to

Timing

Predict and Run 8 min · Investigate 17 min · Modify 8 min · Practise and Make 12 min

Before class

Do the Predict and the senior oval yourself first. Students need Pin the problem down, Pythagoras and the Year 9 idea that an algorithm has computation and decision steps.

The one idea: an algorithm is exact steps that work for any input. Here the steps cut the oval into cells no wider than 1.4 × the reach (the biggest square is about 1.41 × the reach, so 1.4 is on the safe side), with a sprinkler in the middle of each cell. A decision guards the input and a loop places one sprinkler in every cell.

The steps always cover the oval, but they don't always use the fewest sprinklers: the 11.5 m by 4 m oval in Modify needs two when one would do. That is on purpose, to show the gap. Testing awkward ovals (a curved one, a tree in the middle), finding where the algorithm fails and refining it is node 3, the class project, and isn't covered here.

The junior and senior ovals, the reach and the sizes are all made up. A flowchart or pseudocode both work; the numbered steps and the flowchart in the lesson say the same thing.

Running the lesson

  1. Predict: take a show of hands. Most will say 6 or 9. Ask a student to say what happens to the leftover strip.
  2. Paper: the senior oval and the third oval are worked on paper first, a step at a time, with the steps beside you.
  3. Investigate: ask a student to point at the loop and say what would have to be written without it.
  4. Modify: before 11.5 m by 4 m, ask whether the algorithm will place one or two.
  5. Make: ask whether the answer meets the success criterion, and how they know.

Diagrams

A flowchart of the sprinkler algorithm. Read the length, width and reach. A decision asks whether any of them is zero or less: if yes, say not an oval and stop. If no, set s to 1.4 times r, count the columns and rows rounding up, work out the cell size, place one sprinkler in each cell, then say the count and positions.
Investigate: steps, decisions and loops · explain. The sprinkler algorithm

The hard part (on purpose)

Rounding a count down, and putting a sprinkler on the edge of its cell. Ask: what is left over if you round down? Where is the middle of the first cell?

When students get stuck

What you will seeA question to askThe fix
A student rounds 3.57 to 4 for one side and 2.14 to 2 for the other.What happens to the last strip on the short side?Round both counts up: any part-cell still needs a sprinkler.
A student sets the cell size to s, not to L ÷ cols.Do the cells fill the oval exactly?Divide each side by the rounded count, so the cells fit with no gaps.
A student puts the sprinkler at x = i × w.Where is the middle of the first cell?Half a cell in: (i − 0.5) × w.

Answers to the checks

  1. how many cells?: One sprinkler covers a square about 11.2 m wide (made up). The junior oval is 40 m by 24 m. How many sprinklers does it need to be fully covered?
    12. Across, 40 ÷ 11.2 is about 3.6, so a fourth sprinkler is needed for the last strip. Down, 24 ÷ 11.2 is about 2.1, so a third is needed even though the last strip is thin: 4 × 3 = 12.
  2. the cell size: Steps 3 to 5 on the junior oval (L = 40, W = 24, r = 8): s = 1.4 × 8 = 11.2, then cols = 40 ÷ 11.2 rounded up. After that, w = 40 ÷ cols. How wide is one cell, in metres?
    10
    40 ÷ 11.2 ≈ 3.57, rounded up to 4 columns, and w = 40 ÷ 4 = 10 m. The cell is narrower than 11.2 m, so its corners are covered.
  3. Name each step: Here is the algorithm, step by step. What does each step do?
    Step 2: If L, W or r is zero or less, say 'not an oval' and stop → Decision; Step 3: Set s = 1.4 × r → Computation; Step 4: Set cols = L ÷ s and rows = W ÷ s, each rounded up → Computation; Step 5: Set w = L ÷ cols and h = W ÷ rows → Computation; Step 6: For each row and each column, put a sprinkler in the middle of the cell → Loop; Step 7: Say how many sprinklers, and where each one is → Output
    A computation finds a number. A decision chooses between two paths. A loop repeats a step for every cell. The last step hands the answer back.
  4. Run it by hand: Run the algorithm by hand on the senior oval: L = 60 m, W = 30 m, r = 8 m (made up). Write each step's result, then how many sprinklers it places.
    s=1.4×8=11.2s = 1.4 \times 8 = 11.2 (step 3); cols=60÷11.2≈5.36\text{cols} = 60 \div 11.2 \approx 5.36, rounded up to 66 (step 4: a part-cell still needs a sprinkler); rows=30÷11.2≈2.68\text{rows} = 30 \div 11.2 \approx 2.68, rounded up to 33 (step 4); w=60÷6=10w = 60 \div 6 = 10 and h=30÷3=10h = 30 \div 3 = 10 (step 5); 6×3=186 \times 3 = 18 sprinklers (step 7: one in each cell)
    s = 11.2, cols = 6, rows = 3, cells 10 m by 10 m, so 6 × 3 = 18 sprinklers.
  5. Find the mistake: Zoe tries her algorithm on the junior oval (w = 10, h = 8) and finds the left end of the oval is out of reach of every sprinkler. Click the line where it goes wrong.
    line 6
    Line 6: x = i × w puts the first sprinkler at 10 m, the right-hand edge of its cell, so the cell's far corners are over 12 m away. The middle of the first cell is at x = 5, which is (i − 0.5) × w.
  6. What the loop does: What is the loop in step 6 for?
    To place a sprinkler in every cell without writing each position out
    The loop repeats one placing step for every row and column, so the same few words handle an oval with 12 cells or 120.
  7. An exact fit: Run it on an oval exactly 11.2 m long and 11.2 m wide (r = 8). How many sprinklers does it place?
    1
    11.2 ÷ 11.2 = 1 exactly, so cols = 1 and rows = 1. When the division comes out whole there's nothing to round up.
  8. Just over one cell: Run it on an oval 11.5 m long and 4 m wide (r = 8). How many sprinklers does it place?
    2
    11.5 ÷ 11.2 ≈ 1.03, which rounds up to 2 columns. 4 ÷ 11.2 rounds up to 1 row. So 2 × 1 = 2 sprinklers.
  9. Enough, but not the fewest: On that 11.5 m by 4 m oval, one sprinkler in the middle is only about 6.1 m from a corner, well inside 8 m. What does that tell you about the algorithm?
    It always covers, but not always with the fewest
    The algorithm meets the 'must be true' rule, so every point is covered, but it doesn't meet the aim of using as few as possible when an oval is just over one cell.
  10. A different spray: The new sprinklers reach 5 m instead of 8 m. Which step of the algorithm has to be rewritten?
    None: only the input r changes
    Step 3 works out the new s from r. The steps use r rather than 8, so changing r changes every later number without rewriting a step.
  11. A new oval: Run the algorithm on an oval 50 m long and 20 m wide (r = 8, so s = 11.2). How many sprinklers does it place?
    10
    50 ÷ 11.2 ≈ 4.46 rounds up to 5 columns. 20 ÷ 11.2 ≈ 1.79 rounds up to 2 rows. 5 × 2 = 10.
  12. Where the first one goes: On that oval each cell is 10 m wide. How far along the 50 m side is the middle of the first cell, in metres?
    5
    (1 − 0.5) × 10 = 5 m.
  13. A boundary case: Which of these is a boundary case for the algorithm when s = 11.2?
    An oval exactly 11.2 m long
    A boundary case sits right on the edge where the answer changes. At exactly 11.2 m the count is 1, and a hair over gives 2.
  14. Review: corner to middle: Review: a cell is 6 m wide and 8 m tall, with the sprinkler in the middle. How far is the sprinkler from a corner, in metres?
    5
    The corner is 3 m across and 4 m along from the middle: √(3² + 4²) = 5 m.
  15. Run it on the third oval: The caretaker's third oval is 36 m long and 20 m wide, with an 8 m spray (made up). Run the algorithm by hand. Write each step's result, then how many sprinklers it places.
    s=1.4×8=11.2s = 1.4 \times 8 = 11.2 (step 3); cols=36÷11.2≈3.21\text{cols} = 36 \div 11.2 \approx 3.21, rounded up to 44 (step 4); rows=20÷11.2≈1.79\text{rows} = 20 \div 11.2 \approx 1.79, rounded up to 22 (step 4); w=36÷4=9w = 36 \div 4 = 9 and h=20÷2=10h = 20 \div 2 = 10 (step 5); 4×2=84 \times 2 = 8 sprinklers (step 7)
    s = 11.2, cols = 4, rows = 2, cells 9 m by 10 m, so 4 × 2 = 8 sprinklers.
  16. Check the criterion: Now test the answer. Each cell on that oval is 9 m by 10 m with its sprinkler in the middle. How far is the sprinkler from a corner of its cell, to 1 decimal place? Is it within 8 m?
    6.7
    The corner is 4.5 m across and 5 m along: √(4.5² + 5²) = √45.25 ≈ 6.7 m. That's within 8 m, so every point of the oval is covered.

Stretch and support

Stretch: Write the same algorithm in pseudocode with a loop that reads a list of ovals and prints each count, then try a staggered layout, where every second row is shifted half a cell, and see whether it needs fewer sprinklers.

Support: A printed copy of the seven steps and a blank table with columns for s, cols, rows, w, h and the count.

Coach prompt (optional)

For a student who has done the lesson and is still stuck. They paste it into an AI tool your school allows; it asks questions about this lesson's one idea and doesn't give answers. Students see it on the course recap page only through a link ending in ?coach=1: recap with coach prompts.

You are a patient maths coach for a Year 10 student in Australia. Help me understand ONE idea only, from the lesson "Write the algorithm".

The idea: Designing algorithms for spatial problems: I can design an algorithm (using pseudocode or flowchart) that addresses a defined spatial problem.

What understanding looks like:
- Student produces pseudocode or a flowchart that is unambiguous and complete for the defined spatial problem
- Student identifies decision points and loops in the algorithm and explains their role

Mistakes students often make here:
- A student rounds 3.57 to 4 for one side and 2.14 to 2 for the other.
- A student sets the cell size to s, not to L ÷ cols.
- A student puts the sprinkler at x = i × w.

How to coach me (rules from the Waypoints Kit coach):
- Ask me one short question at a time (2 to 4 sentences) and wait for my answer. Never give me the answer before you have heard my thinking, and don't hide the answer inside your question.
- Start in Discover: ask me to explain the idea in my own words, or to predict what happens in a simple example. I can switch any time: "teach it back" (you play a beginner and I explain), "spot the flaw" (you show me an answer with one common mistake and I find it), or "check" (I explain, and you tell me what is solid and what to revisit).
- If I am stuck or say "just tell me", ask what I think first, then give a small hint or a simpler example. Explain only after I have had a real go.
- If I seem to be missing the idea that comes before this one (Defining and decomposing spatial problems), check it quickly, then come back.
- Stay in this idea: don't teach later ideas or add extra content. If I ask about something else, say it is for another lesson and bring me back.
- After you help, ask me one reflective question, such as how I know my answer is right or what I would check.
- Praise my effort and method, not my ability.
- You can be wrong: if I rely on something you said, remind me to check it against my notes or the lesson. If you don't know, say so.
- Use simple words.
- Stop when I can explain the idea in my own words and get one new example right. Then tell me to go back to the lesson "Write the algorithm".

Exit ticket

A sprinkler reaches 8 m (s = 11.2). Run the algorithm on an oval 25 m long and 14 m wide. How many sprinklers does it place?

25 ÷ 11.2 ≈ 2.23 rounds up to 3 columns. 14 ÷ 11.2 = 1.25 rounds up to 2 rows. 3 × 2 = 6 sprinklers.

What each step is for

Where it leads

This covers AC9M10SP03 node 2.

Node 3 (testing, refining and justifying) is left to class: the project is to test this algorithm on the school's own oval, find where it fails, and refine it. Where it leads: the same habit of pinning down, then writing steps, then testing, for any spatial job.