Tuesday, September 24, 2013

Tower of Hanoi

I started Assignment 1 today. Not that I didn't have more emergent work, I was just really curious about it.

Essentially, Assignment 1 is a Tower of Hanoi problem but using cheese and stools instead of rings and posts. The problem reminds me of a University of Waterloo CEMC contest question. The contest had a set number of posts (I believe it was 3) but could have rings varying from 1-4. Contest writers were asked to print out the number of moves needed to get all rings on one column given the number of rings and the beginning placement of the rings (could be on any of the rods, as long as stacked from largest to smallest). Anyway, it was hard. I couldn't finish the problem. I had a structure in place to print the correct output but I had no idea how many moves it would take. Of course, with the introduction of Assignment 1 I learn that there isn't a verified most-efficent method to solve a Tower of Hanoi problem. I'm not sure how Waterloo meant to verify I outputted the correct numbers...

So after an hour or so of work I am in the middle of Step 3. I thought I was done, tried to run the program but got an error. Apparently the name of the class I'm working on isn't defined *eyeroll* I'll take a fresh look later.

I really dislike filling in someone else's skeleton. Not only do I have to do things by their logic, all the parts are so interconnected I can't test as I go. I have to get a lot of code written before I can start to test (unless I want to edit things which could open a rabbit hole I'll never come out of). I prefer to write small bits and test as I go. In my opinion, it makes finding errors easier. Of course this could be considered 'guess and check' programming. I wonder how other people do it... A lot of people seemed to have trouble with Exercise 1 and the blackbox testing. I didn't find it an issue. I only need specific error messages when I'm doing complex structures. Then its time to break out the break points.

2 comments:

  1. Having some initial code (skeleton) for assignments have some advantages. On one hand it might make it easier for students to understand the problem. Also, it makes the auto marking possible. But, I think you should talk about your concerns -- on not being able to test as you go, with your instructor. As you said, it is very important to test your program in smaller chunks and make sure if those modules work fine before moving on.

    ReplyDelete
  2. The requirements of auto-marking hadn't actually occurred to me. It's something I'm still getting used to in this course. Of course, auto-marking is almost necessary with classes of this size.

    ReplyDelete