Archive | March 2014

Programming Math Puzzlers

I teach a 40-minute enrichment class at the end of the day called “Computer-Based Math”, which is an intro to programming, but with an eye toward the math that makes interesting things happen on the computer. A couple of the topics we’ve explored as a class include:


I started with this topic, because when your computer program behaves a little unpredictably, it becomes so addictive and really hooks the students. We wrote programs to generate random numbers, such as coordinates for images, and then to create lists (beginning with arrays in JavaScript) and pull an element randomly from the list.

Jack created this color-matching game. I used it as an example in another math class to explore the difference between experimental and theoretical probability.  It looks like every color should show up as frequently as every other color, but as students played it and tallied results, the Green/Green combination was far more likely than any other. The reason why is interesting. Do you see it?

Jack's Color Match game shows green more than any other color. Interesting reason why.

Jack’s Color Match game shows green more than any other color. Interesting reason why.


Animation is another feature of games that can be addictive to play with, and the basics are pretty easy to understand. Take an object’s (x,y) coordinates and change them at a steady rate, and the object moves faster or slower.

Nathan literally just played and experimented with the rule for changing an object’s (x,y) coordinates and “discovered” an algorithm for making an object move in a circle. It’s really cool. I feel as though I understood why this algorithm creates a circular path at some point in my life, but I don’t remember why anymore. What’s the relationship between Nathan’s rule and the equation for a circle, r-squared = x-squared + y-squared?  Play with the initial values of x and y, and the denominators of the animation rule, and you see some pretty interesting stuff.

Nathan's accidental circle animation.

Nathan’s accidental circle animation.

Gabby made a clever “Frogger” game which explored the math behind collisions.  A circle is positioned according to its center, but a rectangle is positioned by its top-left corner.  Finessing the details of checking whether the outside edge of a circle collided with the outside edge of a rectangle took some thought!

Gabby's Frogger Game

Gabby’s Frogger Game

This class is not standards-based, is not graded, and so we can be more free to explore topics the students are interested in. That said, I look for connections to math standards to help the students with their learning. Goals with expressions, variables, and geometry are easy to include in programming projects. To give the students an audience, we plan mini-showcases a couple of times a semester where we invite other classes to come see our work, we give presentations about what we learned, and we have food (always an important part of real-world meetings). The students are starting to explore functions and the programming behind simulated gravity. When we have some more work to share, I will post it!

Coding Games to Learn Expressions and Inequalities


Before I started our unit on Equations, Expressions, and Inequalities, I asked students if they preferred to learn with lessons and tests, or if they liked projects better. Some of their responses were:

“I like projects better because you can keep working and working until you get it right. Sometimes if you take a test, you get a bad grade and it’s like ‘oh well, there’s that grade down the drain.’ But with a project you get a chance to perfect it.”

“I like projects because you get to work with your friends.”

“I like lessons and tests because I think I learn better when I get to practice a lot.”

“I like projects better because I feel like I really get it when we do a project.”

Most of the responses were very much pro-project, so I made a commitment to do a traditional assessment and also have a creative project on Equations, Expressions, and Inequalities.  My idea for a project came about when a young lady lobbied hard to create computer games:

“Ms. DuPriest, we should all make computer games for a project and then all play them.  It would still be math because we’d be programming!”

Well all right, then. Let’s make math computer games. Creating a computer game is definitely mathematical. Here are the seventh-grade Common Core State Standards that apply.

CCSS 7.EE.A.2 Understand that rewriting an expression in different forms in a problem context can shed light on the problem and how the quantities in it are related. For example, a + 0.05a = 1.05a means that “increase by 5%” is the same as “multiply by 1.05.”

CCSS 7.EE.B.3 Solve multi-step real-life and mathematical problems posed with positive and negative rational numbers in any form (whole numbers, fractions, and decimals), using tools strategically. Apply properties of operations to calculate with numbers in any form; convert between forms as appropriate; and assess the reasonableness of answers using mental computation and estimation strategies.

CCSS 7.EE.B.4 Use variables to represent quantities in a real-world or mathematical problem, and construct simple equations and inequalities to solve problems by reasoning about the quantities.

I have a really difficult time unpacking 7.EE.B.3, which is extremely broad. I have an easier time with the other two standards.  Kids should be able to create equations and inequalities for real-life situations, and they should be able to rewrite expressions to shed light in different contexts.

I decided to have the kids write mini-games like the kind that are on The Price Is Right.  It had so much potential – we could even run a little game show in class, with a host that tells contestants to “Come on Down” and play the students’ games to win fabulous prizes!  I created a rubric and description, and the students and I watched videos of contestants playing TPIR to see what kinds of games were appropriate.


Videos:  Balance Game, Bullseye Game, Grocery Game

In a nutshell, their projects had to meet these requirements.
* Must explain the rules clearly
* Must contain math expressions using variables
* Must use inequalities to test whether a contestant wins or loses
* Must have a paragraph explaining the math in the program, how someone can win, and how someone can lose.

Outside of those requirements, the students really had a lot of freedom to create whatever they wanted.  I teach in a double-block schedule of 89 minutes per class period.  I don’t like using the entire 89 minutes for project work, as it’s hard for the kids to maintain focus on one task for the whole time.  We used 6 or so half-days of 45 minutes each for the kids to work on their projects.  I assigned them into work groups to sit together and collaborate, and overall I liked what this did for their programming. Some kids who had never completed a programming project sought the help they needed and finished one successfully.

The pros of this project:

* Students applied inequalities in a real-world situation through boolean expressions. I really wish boolean logic were introduced in the common core. It may not have seemed like an important part of mathematics before the computer age, but it is now.
* Students gained deeper understanding of variables used in expressions and of the coordinate plane.
* They LOVED creating games. It was really challenging but the engagement was so high. They just thought it was fantastic fun.
* There was quite a lot of learning that went on outside of the standards too. I didn’t expect that algorithmic thinking would be quite as challenging as it was in this little project, but that was the hardest part about it.  It wasn’t doing the math on how to price out 3 gallons of milk and 2 blocks of cheese that was difficult.  It was understanding the breakdown of all the little steps, the algorithm, needed to have a person make their choices, store the choices in variables, do the math on the choices, and then make a comparison in order to see if they won or lost. It was really devilishly hard for many kids to understand creating their own algorithms. As I went through the project, I learned more and more about how to help them by helping less. I started by telling them what to type – and then later developed a flowcharting way of having the students guide me through what they were trying to do in their program.  I will have to play with the flowcharting idea more in the future, because the computational thinking – not the computation itself -really was the biggest challenge, and therefore the biggest gain in learning, with this project.

Some cons of this project:
* I needed to stay realistic that not everyone will learn the same things by doing a project. This is the biggest paradox in our education system today – the knowledge that each student is different in his or her development, background, and motivation – and every student will learn something different from every lesson you teach – but you are held accountable for having every student learn the SAME things.
* That said, some kids wanted to create games that involved really minimal uses of expressions with variables. Or no application of inequalities at all. The games worked and were beautifully written, and clearly learning took place, but I had a requirement that the programs had to use inequalities. Do you force a student to include inequalities when they’re not needed for the implementation of a clever game, just to assess that they know inequalities?  My rubric is pretty straightforward, but I struggled with giving a kid less than a proficient grade for a fantastic program which required a lot of hard work and learning to create.
* The numbers are smaller, but I still have kids who get stuck, stay stuck, and are very shy about reaching out for help. It is still a struggle to move kids along the continuum toward independent problem solving. I suppose that is a universal struggle of life. It’s just amplified when you teach 32 kids in a classroom and there’s no perfect tool for solving it. I did the best I could this time around with structured workgroups and ten-minute mini-sessions. I would signal for the kids’ attention and announce “in three minutes, come to the SMART board for a mini-session on button clicks!” Students would gather around and I’d give them a tutorial.  The next day I might do a mini-session on “if” statements.  These were helpful but not universally so.  I am still looking for tools and strategies and would love suggestions on improving self-efficacy of kids.

Here are some of the better projects created by kids… the creativity and variety in the games was just fantastic, and I loved the work they did.

Gift Card Game by Megan B. Megan’s creative commenting made the game customizable for anyone. She had a great time making the graphics and creating a different screen if you win.

Cookie Clicker by Jake H. A remix of the popular mobile app of the same name. Jake’s version went as viral as it could in the classroom, with every kid in the class clicking the cookie.

Two Player Game by Anna E. A Jeopardy-style game in which you answer quiz questions for money. I loved how she included math expressions by making you solve equations in order to win money for the math questions.

Price is Right by Alison F. A complete package, with challenging math expressions, interactive buttons, and a really user-friendly experience!

Balance Game by Anna R.  Wow. Wow!! Anna wanted to make a game like the Balance Game, but challenged herself to add some randomness to it and make it very unpredictable. The result is really cool and was very challenging to program. Random buttons pop up on the screen, and you have to select the correct two of them that add up to the mystery price.  Anna has quickly become a rockstar programmer in class.  For Christmas she told me her dad bought her a robot and a book about programming in C.  She was extremely excited.

The students submitted their game via a Google Form along with some feedback for each other and for me.  I want to leave you with a quote from Katie T. about this programming assignment.

“I usually do not like the other stuff we did with programming but I thought the way this was set up and they way my game turned out was just awesome. I hope you can do something next year with the students you have. I definitely hope you take this feedback in consideration because I really enjoyed the project and I am sure that the kids in the future will too! ”

I think I’d be a fool not to take her up on that – wouldn’t I?