A Coding Story

By: Iain Brodie

Iain is a grade 7/8 teacher at St. Andrews Public School in the Toronto District School Board. He is learning to code right alongside his students and loves learning and teaching maths in new and innovative ways.

“If you really want to check you understand math then write a program to do it.”  Conrad Wolfram

It could be said that by the time Ontario mathematics students get to grades 7 and 8, they understand quite a bit about the location and movement sub-strand of geometry and spatial sense. They have very slowly and very carefully learned a few simple methods of locating objects on a plane, and how to perform a few basic transformations.

Being introduced to the geometry they are going to learn, the grade 7s could be forgiven for asking:

• That’s it? We get to plot points in four quadrants instead of just one?
• What? Rotations, translations and reflections – again?
• Okay that’s new: dilations. Wait. Aren’t they just similar shapes? Where are we ever going to use these things?

• Finally, we get to do location and movement together – something that makes sense!

• Okay, now that we’ve put all this together, where can we apply it for real?

The one thing that answers all of these questions and puts it all into a challenging, authentic problem is coding.

Scratching a Mathematical Itch

In our classroom we use Scratch (http://scratch.mit.edu) to challenge what the students think they know and understand about mathematics, and to learn new concepts through coding challenges. We all (teachers, too – the students do not get to have all the fun) write programs in Scratch in order to perform seemingly simple sets of tasks.

What is so very interesting about writing code to perform mathematical tasks is that there are multiple ways of achieving the same end. Don’t take my word for it. Go try it. Open a new tab, go to the Scratch website and try it out for yourself. Draw a square.

The students found two different ways to accomplish this. Can you find others?

Go Try It

Now on your own, try coding a triangle. Do not be satisfied with just coding an equilateral triangle. Try to write a program for isosceles, scalene and right triangles. What mathematics do you really need to know in order to accomplish these tasks? What options do you have to weigh? Is there one way that is ‘easier’ than another? Why?

When you are done, reflect on what surprised you about doing this activity.

Coding Challenges

We designed four coding challenges for the students to tackle.

1. Rotate a shape around the origin into all four quadrants of the Cartesian plane.
2. Translate a shape from one quadrant into another.
3. Reflect a shape across the y-axis.
4. Reflect a shape across the x-axis.

Each of these challenges requires that the students really think deeply about the properties of shapes, and how they relate to placement and movement on the Cartesian plane.

They quickly found out that they needed to integrate their approach to accomplishing these tasks. Using just the perimeter approach or just the vertices with coordinates approach produced a set of code that was long and unwieldy. By combining the two, the students wound up being able to use loops and sets of repeated code by making their own blocks.

Through trial and error, and deep thinking, the students managed to come up with a multitude of ways to solve the challenges. Along the way they had to combine what had been discrete knowledge: properties of shapes, location and movement had to be used together. They discovered that there are any number of ways of solving a coding challenge. Some were longer, some were shorter. Some used loops, some used their own coded blocks. They had definitely demonstrated their mathematical understanding by writing a program in Scratch. In fact, they had demonstrated a much deeper understanding of geometry than if they had only done these challenges using paper and pencil.

Taking It Further

Some of the students noticed a pattern between the coordinates as they rotated them around the origin, and translated them around the Cartesian plane. When translating a shape they noticed that they were adding or subtracting certain amounts to the x and y of the coordinates, and that these amounts dictated how far and in what direction the translation would go. They had discovered and were using vectors and vector addition.

As they dug further, they noticed patterns in the rotations of 90° as well. What they could describe in words, and knew that there was something numerical going on, was a simplified form of the rotation matrix that is produced by a 90° rotation. What they had been doing informally was multiplying their coordinates by a matrix.

Without these coding challenges, without having to think deeply about shapes, location and movement, none of these extra topics would have come up. None of the integrated ideas between properties of shapes, location and movement would have been dealt with. We would have kept on learning very carefully and very slowly. Instead, we all had a lot of fun and pushed back the boundaries of what grade 7s and 8s are capable of learning when they learn mathematics through coding.

References