Refactored assignment 1 solution.

While my original solution worked, it was more involved than necessary.
Refactored solution to match (more or less) what was shown as a solution at the
beginning of Lecture 3.