15-110 Fall 2010 Homework 9

Due Monday, November 8, at 10pm (no late submissions accepted!)

Note: to do this homework, you should download Homework9.zip, then unzip it, edit the files, rezip, and submit that zipped file to Autolab.

Read these instructions first

This is an optionally collaborative programming assignment.  Here are the guidelines:

  1. You may work with 0, 1, or 2 other students (all currently enrolled in this course).

  2. Whether or not you work with another student, you should still submit your own solution (which may be identical in part or in whole to the solutions from the students with whom you collaborated).

  3. Very clearly list in a comment at the top of your files everyone else you worked with, if even just for a short while.  You may list up to 2 other students this way.

  4. If you list someone in your files, they must list you in their files, too (collaboration is a two-way street).

  5. You may not collaborate with any other students besides those listed at the top of your files.

  6. Do not divide the work among your team ("you do part 1, I'll do parts 2-3, etc..."). You will learn much more if you actually program together with your friends, in the same place and at the same time, discussing the problems and coming up with solutions together. This is the great advantage of collaborative programming!

  7. While we encourage you to join a team, it is not required.  You may do this assignment entirely on your own.

·         Do not change any file names!  Each problem that includes a changed file name will be docked a 50% penalty.

·         Include your name, AndrewID, and section clearly on the top of each file in your assignment.

·         Place all your solutions in a single file ZIP file (extension.zip). Once again, start with Homework9.zip. No other file formats will be accepted. You need to start by downloading a ZIP file that contains a template (a file ending in .py) for each problem in this homework (problems 2 and 3 share the same file).

·         Show your work. Correct answers without supporting calculations will not receive full credit.

·         How to submit:

Your submission is not completed until you see that text!!!

Once again: Late submissions will be rejected.

Log

We want to gauge how much time you are spending on each homework and how you are using your resources. This week we are going to record your answers using an online survey. An email with the details will be sent to you.

Problem 1: Snake with high scores (30 points)

In the file snakeWithHighScores.py, implement a new feature of the game Snake: when the game is over, the top 5 highest scores are displayed and stored into a file for later retrieval. More details and guidance are provided in the file snakeWithHighScores.py

Problem 2: CMU courses (30 points)

In the file courseSchedule.py, write the function printCoursesInDepartment(htmlSchedule, department) that prints all the courses (number, title, and credit units) offered in a given department at CMU. The data in htmlSchedule is retrieved from the web, at https://enr-apps.as.cmu.edu/assets/SOC/sched_layout_spring.htm More details and guidance are provided in the file courseSchedule.py.

Problem 3: Choosing CMU courses (40 points)

In the file courseSchedule.py, write the function printCourseSelection(htmlSchedule, departments) that prints a selection of CMU courses (number, title, and credit units) from a given list of departments, totaling at least 40 credit units. You are not required to optimize the choice of courses, nor take into account conflicts and prerequisites, but the list must not be "trivial." Trivial lists include: (1) printing all the courses in the given departments; (2) printing only courses from one department, ignoring the others (try to print courses from a good mix of departments instead). More details and guidance are provided in the file courseSchedule.py. The utility function isValidNumberString(s) is provided for your convenience (although you are not required to use it if you don't want to).


Problem 4: Bonus/Optional: Choosing fewer courses (10 points)

For bonus, write a function printMinCourseSelection(htmlSchedule, departments) that works like printCourseSelection(htmlSchedule, departments), but chooses the minimum number of classes that satisfies the 40 credit hours requirement.