Feedback during the 3rd week of my C++ class

Dang! It is always nice to get good feedback like this.

This was in one of the mini-essays I assigned in my C++ class (reading about & discussing problem solving techniques), so I wasn’t expecting it!

“Coming into the class I was very nervous. My friend who has taken this course before by other unnamed teacher said it was the worst and that if I didn’t understand this class that I would struggle going forward. Scary right? For me it was. But as I continue to read the content you have written to teach and share with us, I am put to ease. I find myself smiling and laughing at your videos and text, which is something I did not expect coming into the class. So while I am still terrified of falling on my face, I have faith that I will make it. And that is not something that I previously thought.”

Programming for Discrete Math

  • Josephus Game
  • Magic Trick
  • Tennis Matches

I like using programming in the classroom. I’ve never seen programming really used much in any of the math classes I’ve had in the past, save from some odd MatLab projects (of course I opt for NumPy or SciLab – Go FOSS!), and sometimes reading paragraphs of math problem examples in a textbook just makes my eyes glaze over. Rather than try to demonstrate this stuff on the whiteboard, I decided to write some quick Python/PyGame programs for the examples from the textbook we’re using.

Another pro of this is that it helps me “grok” the content. I might read over something and think “yeah, that makes sense”, but I don’t really know it until I put it into practice, and the best way for me to put it into practice is to make it a program. When applying it in code, it’s more likely I’ll remember the fine details much better, just through the entire process of working on the program step-by-step.

Not sure if I’ll have my students do any coding (various prereqs, they might all know different languages), but it might be nice in the future!

random test generator

random test generator

What do you do when you want to write a take-home exam, but want to discourage students from simply copying off each other?

If you’re a programmer, you write a random exam generator. ๐Ÿ™‚ If you’re not a programmer, then you can probably find an existing one out there much nicer than mine… but oh well.

This is a C++ program that reads in text files – each question position has a “deck”, and a deck file has a list of questions that are interchangible (e.g., “declare an int”, “declare a double”), and then you have a series of decks that represent the amount of questions in the exam. Each question item in a deck has a serial number as well.

The exams are generated and output to .html files (I decided to do this because it’s easier to maintain the formatting if I copy it into a LibreWriter file), and a key is also generated, with all the decks and all the questions and their answers.

I’ll probably go extend this to list point values as well, I like putting that on exams. Then I have to go write my Programming Fundamentals exam 1. Whee!

Jeopardy for Computer Science

Sometimes, class gets quiet. Especially during review days, students usually don’t speak up on their own to ask questions. So, this semester I wrote a little Jeopardy program and used it for both of my classes.

The students at the community college I’m teaching at seemed to enjoy it; I was even asked to make more questions and come back with candy as a reward next class. So I will. I upgraded the Jeopardy program and wrote new questions dealing with different topics in Computer Science / C++, and it’s all ready to go!

This program is written with C++ and SDL2, as well as my Kuko framework. Since the class is about C++, I thought that it would be good to write the program with C++, instead of doing it as a webapp (which would have taken less time, admittedly!)

You can download the game code here: https://github.com/Rachels-Courses/CompSci-Jeopardy

It also requires the Kuko library: https://github.com/moosader/kuko

As well as SDL2 and Lua 5.2!

Kind words

When I was a student, I always tried to leave nice messages on my final exams / final submissions, so it is really nice to get the same from my students now that I’m teaching. ๐Ÿ™‚

I’m going to keep these for posterity!

I’m sorry it’s late. Have a great summer, and thank you for being such an awesome C++ teacher and teaching us how to get a good job as a programmer. ๐Ÿ™‚

 

It was a great semester learning from you and you definitely helped me to accomplish my goals in starting to learn the basics of programming. I wish you all the best […] Saying thank you isn’t enough for what you did to help me learn and giving me the Arduino as a gift but I promise I will learn from it and will always remember you ๐Ÿ™‚

Visual problem solving with SDL2

I am assembling some projects in my Challenge Topics repository on GitHub (https://github.com/Rachels-Courses/Challenge-Topics). These are projects that I’ve written to show in class, asking the students to come up with a better algorithm to solve some problem.

Here are some examples:

Screenshot-Searching

With this one, a linear and a random search are implemented to search a sorted list. The challenge is to ask students how a better searching algorithm can be done for our sorted list, where we do searching more intelligently than just going from the beginning to the end.

You can also expand this to talk about creating a data structure that auto-sorts when items are inserted, and whether to implement this by sorting immediately after an insert, or do a smart-insert and look for the appropriate position for the new object.

 

Screenshot-Travelling Salesperson

For this one, a list of cities are generated at random points on a map. The random paths generator essentially adds paths between cities in the order that the cities were generated. The challenge here is to ask students how to build a more intelligent route, visiting all cities once, and returning home afterward.

So for example, in the above screenshot, the salesperson goes from Grandview to Leawood to Raymore, which is a bit nonsensical.

You can also demonstrate Dijkstra’s Algorithm as well.

 

Screenshot-Collision Detection

Another problem we can look at is detecting how two objects are colliding, such as in a game. There are multiple ways to handle it – for example, you could do bounding-box collision detection and check the perimeter of the images themselves, each edge. Pros and cons? Could be empty space colliding, such as the top-right of the bunny and bottom-left of the dog.

Another option is to use the distance formula and figure out what a good distance is before considering the two images colliding. This works well for circular objects, but might not work as well for an oblong object.

Or, you could do a combination of both, maybe each object has several bounding boxes within it (like the dog’s head, and dog’s torso).


 

The idea behind these exercises isn’t to necessarily get the “most efficient” algorithm to any given problem, but to have students brainstorm and actually think about the problem visually, instead of having everything be intangible. Having pure console-based applications using just cin and cout can be boring, and even when implementing something modelled on a real-life system, it can be hard to really get into it. Even many command-line programs use something like pdcurses to give more organization to the presentation of the program.

So by using the SDL library, we can still write C++ code and demonstrate some problems in a more graphical way. Even if SDL is not available on the students’ school computers, if the teacher has a laptop they can install SDL2 on their own and display it to the entire class for a more social lesson.

Learn more about SDL at: https://www.libsdl.org/

And my challenge repository is at: https://github.com/Rachels-Courses/Challenge-Topics