CMU 15-112: Fundamentals of Programming and Computer Science
Homework 9 (Due Wednesday 28-Jul at 5pm)


Important notes:
Here are the rules for collaboration:
  1. Everyone must read all of these rules, even if you opt out of collaborating.
  2. Collaboration is optional.
  3. Collaboration is in groups of 2-3, arranged by your TA.
  4. If you do collaborate, you must arrange this with your TA from your recitation, who must know which students in the recitation are collaborating with which other students.
  5. You may only collaborate with other students in your recitation.
  6. You may not change your collaborators once you have chosen them (except with written permission from Mike or Sara if your partner becomes nonresponsive).
  7. You must list the andrew id's of your collaborators in a comment just above your solutions to this section.
  8. You must be an effective collaborator, working together as much as possible.
  9. It is strictly forbidden for you to simply copy the code of your collaborators. That is not collaborating, that is cheating. Instead, you must type all your own code, without copying from others. You can discuss all parts of the problem with your collaborators. They can even help you debug. But still, you must write your own code.
  10. Reminder from the syllabus: when we say "do not copy" we always mean visually, verbally, electronically, or in any other way, even if you copy and modify it.

  • To start:
      • Create a folder named 'hw9'
      • Download these files into that folder:
        1. hw9.py
        2. cmu_112_graphics.py
        3. cs112_n21_week4_linter.py
      • Edit hw9.py using VSCode
      • When you have completed and fully tested hw9, submit hw9.py to Autolab. You may submit up to 5 times and, as usual, only your last submission counts.
      • There is no autograder for hw9. The TA's will manually grade your last submission sometime soon after the hw deadline.
  • Do not use sets, dictionaries, or recursion.


    1. Tetris [100 pts] [manually graded]
      Reminder: Any collaboration must be earnest collaboration, and you must list your collaborators. If you submit code that you are unable to thoroughly explain, or if you could not rewrite Tetris from scratch without referencing your submission, you have not collaborated well.

      With positive collaboration in mind, write Tetris according to the design given in this step-by-step tutorial. You may not use a different design, even if you think there's a better way to do it (there probably is, but you still have to do it this way). This may seem limiting, but sometimes you have to write code according to a specific algorithm, rather than writing code to solve a specific problem. This is also meant to keep you from hitting a dead-end with a less-thought-out algorithmic plan. If you wish to customize your implementation, see the note on bonus features below.

      To get full credit, you'll need to complete the basic implementation according to the design spec (up to and including step 7).

      If you decide to add some more bonus, which we do not require but we heartily encourage (not for the few points you might earn, but rather for the joy of learning and creating), then:
      • Have the code run normally, without any bonus features, so the TA's can easily grade your submission against the spec.
      • But if the user presses 'b', then the game switches to bonus mode, and the bonus features are activated.
      • When the user presses 'b' to activate the bonus features, a description of all the bonus features is printed to the console. Be sure to print enough of an explanation that the TA's can understand how to use and grade your bonus features.

      Have fun!