Tuesday, October 25, 2016

Teaching Computer Science and the Good Idea Fairy

The Good Idea Fairy struck again today. I have been taking about data checking and data safety with my freshmen lastly. One of the things we talk about is parity checking (I blogged about that three years ago at Making Magic With Software) Garth Flint offered the term “Good Idea Fairy” in a comment there.  In any case I started to think about other things we do in computing for data integrity. Things like cyclic redundancy check (CRC).

CRC is an important topic and I do talk about it. The math is not something I want to do with my freshmen though. Still I wanted something that would be quick and easy to have them do. That lead me to think about check digits.  They are used in all sorts of things and yet some of them are fairly easy to calculate. The check digits used for the machine readable numbers on passports for example.

The formula is simple. The first digit is multiplied by 7, the second digit by 3, and the third digit by 1. Then the cycle repeats so the fourth digit is multiplied by 7 and so on. The results are added together and the result divided by 10 with the integer remainder being the check digit.. imageCalculating the check digit for a birthday (in the format yymmdd) is pretty trivial but gives students an idea of what is involved.

So I did that with student in class. Step two of the Good Idea Fairy is now I have more ideas for programming projects.

The easy version is to calculate a check digit from a set of numbers entered. That’s ok. And maybe fun for a bit. But I was thinking – suppose I created a data set of numbers with check digits and had students write code to scan the file for invalid data. Or just build a new data set with the check digit added. Now those would be more interesting. That may happen soon.

What is the latest project or teaching idea the Good Idea Fairy has hit you with?


Anonymous said...

LRC is a simple cumulative XOR algorithm probably suitable for freshman classes, with the added benefit that it's actually still used in real life for serial data integrity. (mikez)

rwhite5279 said...

Thanks for this post! For the moment, *you're* my Good Idea Fairy.

I'm aware of parity checking, but had never thought to have students explore this idea with their own programs. Reading this post yesterday led me through an exploration of various Digit Checking algorithms. I wrote a quick little UPC tester, grabbed a PowerBar from my pantry, and ran the validator (being sure to include the printed digits on either side, for a total of 12 digits). Good fun, and good timing in my curriculum.

To make it a little more interesting in the classroom: bring items with UPC codes on them--candy bars might be an interesting possibility--and give students the first 11 digits only. They can "earn" the prize by correctly calculating the final check digit on the UPC code.

Thanks again for a great post!

Alfred Thompson said...

I love the UPC idea. I wrote a version of a UPC check digit generator myself today. I may use it in the future with classes. I should probably take a good look at LRC as well but, hey, doing something involving candy is always good to focus. :-)

Garth said...

I am going to do a Coding Club with 6 - 8 graders for 6 evenings in Nov/Dec. (I volunteered. I thought the military had broke me of volunteering. I am an idiot.) I am going to use Corona SDK and make a game the kids can put on their Android phone. So I thought a simple game that would work well on a phone would be Wack-a-mole. It is very simple until you start coding it out and start thinking about 6 - 8 graders. We shall over come. I love the Good Idea Fairy. She keeps life from being boring.