Checking in my answer to ProgrammingAssignment2.