First pass at writing the functions required for this assignment, using significantly more descriptive variable names than the example code suggests.
Added comments.