Ceiling Staring 101

There is a professor at the university teaching the same Python course I am teaching here at the high school.  If the kids sign up they can get dual credit.  I have met him a couple of times and he knows Python really well.  I on the other hand can spell Python.  He is not using any text book so it makes it a little difficult to synchronize the courses in any way.   As a result I like to see what he is teaching and what assignments he is giving his college students so I can use some of them in my course.  The courses need to be somewhat similar to rate the dual-credit classification.  I also want his assignments so I can try to do them.  So far all are well within my capabilities as a beginning Pythonner but I hit one of his that was much more than just interesting.  It is/was a pain in the rear.  I got part of it working and decided the other part was not worth the effort.  Here is the problem.

The goal of this exercise is to write a script that asks the user to enter an integer, and then displays the names of all of the positive integers up to that number.


Please enter an integer: 3




The challenge is to write a script that will work for “large” numbers. 

I got up to the two digit part working and that was ugly enough.  Figuring the logic to the problem took me quite a while, not because it was particularly difficult but more because there were several possible approaches.  The university prof sent me his solution, which was much simpler that mine, but there was a step in his logic that was simply not obvious and, if not seen, can make the code really ugly.  This sort of points out an important lesson in coding, getting the correct algorithm or logic is usually more important than being an expert in a language.  The code solution for this problem was well within me and my students’ capabilities but that little error in how to solve the problem led to a major can of worms.

Typically when I hit a code solution that is a can of worms (Isn’t “can of worms” an official programming term?  If it isn’t, it should be.) I suspect one of three things: 1. I screwed up and need to start over on the problem, or 2. the problem really is a can of worms or, 3. I do not know enough of a language to solve the program in a nice elegant manner.  At my present knowledge level of Python I usually suspect 3 but in this case it was a 1.

When I hit a can of worms problem I sits and I stares (usually at the ceiling) in an attempt to see another way to solve the problem.  In this case I had a solution; I knew the solution would work so I kind of got hooked into making that solution work.  I did not stare at the ceiling long enough.  It is a lesson I need to impart to my students, not necessarily the ceiling staring part but the think before you type part.  They all want to read the problem (usually incorrectly) and start hammering on the keyboard immediately.  I also need to point out if it is ugly, think more or read more.  It all goes back to problem solving which is by far the hardest thing to teach to a 17 year old.

Today we are going to rip apart one of their assigned problems: Count the number of even digits in an integer.  Since there are several ways of approaching this problem and considering my own “can of worms” issue it would be a good time to discuss programming away from the computer, or Ceiling Staring 101.


2 Responses to “Ceiling Staring 101”

  1. Dave aka Mr. Math Teacher Says:

    “It all goes back to problem solving which is by far the hardest thing to teach to a 17 year old.”


    This extends to most adolescents for that matter…I might even generalize the dilemma to “thinking” on demand. Is it even developmentally appropriate to make students think or solve problems? I am starting to wonder…Or, perhaps, we’ve simply weakened the gene pool over the past century by removing the thinking aspect faced by adolescents of old?

    More likely, I believe the fear of failure, or the potential to be perceived as a failure, makes many loathe to express themselves publicly, such as in a classroom environment. Developing the trust necessary to lower our students’ guards takes an enormous amount of time, and even then may not be sufficient, as I’ve experienced, especially with my advanced students.

    Lastly, reading this post made me flashback to my times debugging Pascal and Fortran code. I disliked doing so with extreme prejudice; those who program successfully must be the most patient souls in the world, or the brightest.

  2. Keith Decker Says:

    My immediate reaction is, what pedagogic goal is this problem trying to reinforce?

    In our (university level) intro CS I course, each week has a very specific goal in mind (using the Program by Design / HTDP2e curriculum), and the homework typically reinforces whatever the previous week’s focus was (composition, conditionals, structures, mixtures, lists, …).

    The second problem [“Count the number of even digits in an integer”] I’ve seen before in the context of lists [“sometimes, your data is not a list, but you can treat/coerce it into that form and then use the ideas we talked about this week”] but the first problem seems unmotivated (e.g. not obviously an instance of a common pattern you might see time and time again in many different applications). Contrast filter/map/reduce over lists/arrays in the second problem, an idea that appears in processing database queries, statistical analyses, photo/sound manipulation, etc. etc.

    Since we are also trying to teach a set of problem solving steps (what to do and what to think about as gradable steps between the textual problem description and the actual code) in the first course we try to stick to problems that fit that approach (which is about 80% of real-world stuff anyway), until late in the semester when the students have a good grasp of the basics and then we can start throwing curves (“Our design recipe led to this sorting algorithm, but can we do any better? Yes, actually…but it is not obvious!”)

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: