Slashdot Mirror


Memorable Programming Assignments?

Albert Schueller asks: "This fall I'll teach introductory programming for the third time. The class is generally populated by students from a wide range of backgrounds and interests-liberal arts and science types. While we use C++, the language isn't really the issue. Rather, the goal is to introduce basic programming ideas like loops, logic, modular programming etc. What are some of your favorite programming assignments that would be appropriate for students at this level?"

5 of 127 comments (clear)

  1. Mazes and parties by linuxwrangler · · Score: 5, Interesting
    Solving a maze is a good example of recursion.

    Still, my most memorable freshman programming assignment (punch cards/line printer/mainframe no less) was to simulate a cocktail party.

    The party was a two-dimensional array representing the room. At the edge was a door and in the center was the bar.

    You fed the program a list of guests including name, arrival time, planned departure time and how interesting the person is.

    Guests arrive and go first to the bar. From there they mingle by trying to move a square at a time if it will make the average "interestingness" of those surrounding that square more interesting that the average surrounding their current square.

    If the guest cannot move to a square such that the surrounding guests are, on average, more interesting the guest is then he will go back to the bar.

    One last provision...each trip to the bar causes a guest to become one point less interesting but to think he is one point more interesting and each drink also increments the planned departure time by one.

    --

    ~~~~~~~
    "You are not remembered for doing what is expected of you." - Atul Chitnis
    1. Re:Mazes and parties by ChadN · · Score: 5, Funny

      Solving a maze is a good example of recursion.

      So is solving a maze.

      --
      "It's overkill, of course. But you can never have too much overkill." - Anonymous Slashdot Coward
  2. You guys are all nuts!!! by Anonymous Coward · · Score: 5, Interesting
    I taught second quarter C/C++ about five years ago; the students were supposed to have had at least one quarter of C/C++ under their belts. I started off trying to give them an appreciation for the imperfection of computers. For instance, I tried to teach them that if you're dealing with ints, and you add 1 to (2^31 - 1), you don't get 2^31, but rather -2^31. I also tried to teach them that floats become granular at 2^24, i.e. if you add 1 to the float 2^24, you don't get (2^24 + 1), but rather (2^24 + 4). The class revolted, went to the dean [who let most of them transfer to a different section], and I was nearly fired.

    If you're one of the posters on this thread who thinks that a bunch of liberal arts losers are going to program pool table simulations and Mandelbrot sets, then you're living in a fantasy world.

    The following is THE MOST DIFFICULT homework problem they were able to solve: Write a C function that takes an int, and returns one of the strings "st", "nd", "rd", or "th" to describe the ordinality of the associated number [e.g. 1 returns "st", for "1st", 2 returns "nd", for "2nd", 3 returns "rd", for "3rd", 4 returns "th", for "4th", etc.] The trick was that e.g. 11 returns "th", but 21 returns "st". A handful of them were able to get that right.

    The final project was to write a program that would take large files and decompose them into smaller chunks, each small enough to fit onto a 1.44MB floppy. Not a single student in the class came close to finishing the project, and the class included at least three fellows who were already programming for a living.

  3. First year by bertok · · Score: 5, Interesting
    I studied Computer Science at the University of New South Wales. The introductory computer course in first year was "Comp 1A". Instead of C, C++ or Java, we started with a language called Haskell, a pure functional language. Everything has to be an input to a function, or an output - no local variables, no assignment, no loops. The only available form of high level flow control is recursion. After a few weeks, we could write functions to solve simple problems like: Write a function that has an integer input 'n' that returns a square character array representing the image of a square with side-length 'n'. Trivial stuff, even for beginner programmers.

    Sometime in the fourth week, our lecturer announced the eagerly anticipated first Assignment. I couldn't wait, because I expected to ace it, after all, I had years of programming experience, a huge advantage over my peers. Not so: We had to write an Optical Character Recognition (OCR) program. I was stunned. I had never done anything that complex in my life, in any language, and now I was being asked to do it in a functional language! However, many people achieved recognition rates over 80%, and some people rates as high as 98%, even though most students were first-time programmers. It just goes to show what people are capable of when pushed.

    The same lecturer (Andrew Taylor) later came up with a whole series of Evil assignments -- his students tell stories about them to this day. For example, our second assignment in Comp 1A was to write an AI for the card game Hearts. To mark the assignment, he wrote a system that ran submissions in randomly chosen four-player games automatically, and ranked them by total score after some number of games. Half the marks were based on the performance of your AI! He even made the ranking software available beforehand so that students could test their algorithms against each other in mini-tournaments.

  4. What I've wanted to try by bluGill · · Score: 5, Interesting

    I've always wanted to teach a class just so I could give this assignement: Write a RPN calculator that does addition and subtraction, no more. A few rules that are different from every other project: other class mates will see your code; redit will be lost for implimenting functionality byond addition and subtraction; the due date is next week, but you get MANY extra points by getting the assignment to me sooner; class dissmissed, get to work.

    Then the next week I would copy everyone's program, and randomly hand it out to other students, with a new assignment: add multiplication and division to this program, and fix any bugs in the code. Time counts again. Note that even though I say is the random, I will in truth pick out who gets what, those who did a good fast job get aweful programs to work with, while those who did a bad job get good ones, and there will be a comment as each studnet picks up his assignment that this is an example to learn from. After they turn in the completed assignment (remember time counts) they will get another assignment, write a short paper to the author of the program you graded on what you found good/bad. (english skills don't count so long as it is understandable, ideas do)

    Finially, everyone see's how their program looked after the second guy got done with it, and the comments. Grades for the second half will take into account how the first half turned out, so someone who got a horrid, non-working assignment and took all week to make some stupid algorithm work will get as much points as someone who was able to get their assignment done in an hour. How long it took the second programer to modify the orginal code is a factor, but minor since bad programs should not take down easy to modify code.

    Just make sure that this is done early in the year, if they are supposed to learn C++ in your class, this won't work, by the time they can do this all their other classes are in crunch time and a good student may notbe able to get this done quickly. I recomend giving this assignment the first day of class, if they can't hack it then, they need more expirence than your class can give.