CMU 15-110 Spring 2019: Principles of Computing
Homework 4 (Due Monday 4-Mar at 8pm)

This hw is entirely solo. See the syllabus for details.
To start, download this file:
  1. Group Code Tracing [10 pts, not autograded]
    Meet with a TA from your recitation (but outside of recitation) for 30 minutes of small-group CT practice. Your TA's will contact you soon to arrange times for these sessions.

  2. alternatingSum(L) [10 pts, autograded]
    Write the function alternatingSum(L) that takes a possibly-empty list of numbers and returns the alternating sum (where the sign alternates from positive to negative or vice versa). For example, alternatingSum([5,3,8,4]) returns 6 (that is, 5-3+8-4). Also, if L is empty (no values), return 0. If L is not empty, add the first value into the result, then subtract the second, and so on.

  3. median(L) [10 pts, autograded]
    Write the non-destructive function median(L) that takes a list of floats (or ints, which you can treat as floats) and returns the median value, which is the value of the middle element (if there are an odd number of values), or the average of the two middle elements (if there are an even number of values). If the list is empty, return None.

  4. Invaders! [70 pts, not autograded]
    Here we will write a somewhat simplified but still playable version of the arcade game Invaders! Your game should closely match our version, which may be different from other Invaders games in some key ways. For a quick demo, watch this
    Important note: we have provided headers in the starter code for all the functions you have to write, along with super-helpful hints and clues and suggestions in the comments!

  5. Bonus/Optional: Invaders++ [up to 2.5 pts, not autograded]
    Spice up your Invaders game. Be sure it still follows the original spec, to get those points, but add additional fun game-enhancing features. Be sure to describe the bonus features in a comment at the top of your file, so we are sure to give you credit for them!