# An example of computational thinking as a sense making tool in the mathematics curriculum: the locker problem

I need to write a much longer post detailing my work in Norway and all the things I’ve learned, but I first want to publish this very small example of some of of the things I’m working on.

Here’s a little bit of background. The Ministry of Education of Norway has decided to make programming part of the 1-13 mathematics curriculum for all students in Norway. This requirement will be part of an overhaul of the entire curriculum in all subjects launching in 2020.

In addition, the Norwegian government has allocated a significant amount of funding to support training and professional development for teachers. Since most math teachers have very little previous exposure to programming, this is going to be a very big undertaking.

I’m working with some faculty at the Center for Computing in Science Education at the University of Oslo to help develop training and lessons for teachers in Norway. At the moment, we are developing training for a cohort of year 8-10 math teachers in the Oslo Kommune, which will consist of a single day workshop followed by 3 half day workshops later this year.

Our goal is to train these teachers in the fundamentals of python programming, and also to help them find ways opportunities for where programming and computational thinking can extend and enhance mathematics education. I’ve been re-reading Paper’s Mindstorms lately, and again am taken with Papert’s description of how the computer can create an environment where students are free to explore and test their mathematical ideas. There is another blog post I need to write about re-reading Papert—it’s amazing to me how relevant this book is to educational technology and computing 20 years after he wrote it.

All of this has put me on a quest to find interesting problems in mathematics that might be fun to explore with computing, and this is where I want to share the example of the locker problem.

I can clearly remember when I saw this problem in my 8th grade Algebera class. Newly (over)confident that I was proficient in solving any equation involving x, I was completely thrown by this problem because there didn’t seem to be any equation I could write. My 30 year old memory is hazy beyond that, but I mostly just remember wanting to know the answer, and not really having any tools to explore it. Were I teaching this problem today, I’d love to send my students off with whiteboards, and have them make sketches trying to find patterns for the first few students.

There’s so much you can do to think through this problem with pen and paper, but now, I also got to thinking it is a great problem to also explore with a bit of computing.

I’ve created this Juypter Notebook for my first draft of an activity that explores the Locker problem with computing. Here’s a version that is viewable on the web.

In creating this activity, I decided to take a scaffolded code approach. I wanted to provide students with some code that they could use for their own explorations, and assume they have only a very basic understanding of python loops and arrays. I created a Locker class that held the number of the locker, the current status of the locker (open or closed), the number of times the status has been changed, and the list of students who “touched” the locker, along with functions to “flip” and print the status of the locker.

From this, students can create an array of lockers, and then go about flipping various lockers to explore the problem. One goal of the assignment is to get them to see how they could simulate the problem and then look for patterns to generalize.

From here, I’m hoping students can do a bit of noticing and wondering about the patterns they see in this set of lockers, or possibly see what the patterns look like when they do the same action on 100 lockers.

I’ve never taught middle school before, but, my thought is that if students were comfortable with the basics of programming and the Juypter environment, they could walk through this notebook and use it to test and expand the initial work they did to think about the problem on paper or a whiteboard.

At this point, I’d love some feedback. Does being able to quickly simulate all 100 or 200 lockers give students more insight into the problem? Does it allow students more room to explore their own ideas, perhaps seeing what happens if you skip a student in this process? There definitely seem like plenty of ways for students who are comfortable with programming to extend this code—perhaps printing a list of all of the open lockers, or a function that will print the number of times a locker was touched.

Love the locker problem! I think I agree that it’s a problem where computation can help with understanding. The coding is pretty easy (after explaining the % operator, of course) and then ramping up the locker number is easy too. Then, as you say, encouraging the students to find patterns is a great next step. Here there’s some hope they’ll notice the squares, but I bet someone would. Then getting the students to think about why that happens leads to some great insights about factoring, I think.

My question: To accelerate this, what would happen if you skipped teaching the coding and just showed the computational results?

Thanks Andy! I think part of the goal here in the Norwegian curriculum is to teach students to be able to develop models like this on their own, so I think jumping to the results might be a bit too much of a relief. Personally, I also think it might be giving too much away for this problem—it seems more like look at this list of numbers and tell me what pattern you see, where I hope students would use the notebook I’ve developed only after they’ve spent some time thinking about the problem on just paper or a whiteboard.

I’m impressed with how much computational thinking/programming is infused into the university curriculum for students who are studying natural sciences. here. In the first semester, all students in natural sciences take a course in programming, a course in calculus, and a course in numerical methods that seems to bridge the two disciplines. Most of the subsequent physics courses also heavily incorporate some sort of computational modeling. Even the intro bio course at the university has a significant computational modeling component.

John, thanks for sharing your thoughts on your blog. I am consumed at the moment by infusing Snap! programming into my 9th grade honors physics class at a public school in PA. In my first run this semester my students have programmed 1D kinematics and dynamics with a differential approach. My vision is to use Snap! almost daily in all kinds of ways for the benefit it offers and to develop fluency in coding in Snap! I have big plans for version 2.0 next year. I hope to have this feature to my class developed by next year so I can show what I am doing to my district admin and advocate for CS curriculum development in the elementary and middle school. I don’t want Norway to get too far ahead 🙂

Michael, this sounds great. I’ve done a lot of computational modeling with Python/VPython/Glowscript in 9th-grade physics, and some snap programming in my CS courses, but never thought of using snap in physics. I’d love to see more about what you are doing.