teaching machines

Debugging Secret Coders

January 31, 2019 by . Filed under pop computer science, public.

My sons have thoroughly enjoyed Gene Luen Yang’s six Secret Coders books. They are graphic novels about three teens who fight evil with programming, and their weapon of choice is the Logo programming language.

Last summer we were reading the fifth book in the series. It ends with this challenge to complete a code snippet that draws a triangle, square, pentagon, hexagon, heptagon, and so on, up to an 18-gon:

My son Lewis said there was a bug in the provided code. Sure enough.

Can you spot it?
The make "nsides (nsides + 1) needs to moved inside the repeat loop. As it stands, the completed code would draw a triangle 18 times.

I follow Gene Luen Yang on Twitter, and I suggested that Lewis message him to report the bug. Lewis did, and to our delight, Yang responded:

But that wasn’t all. Yang sent Lewis a copy of the book with this inscription:

Social media is the place where our heroes are made real. Thanks, Gene Luen Yang, for your passion, books, and investment in my son!