My solution to the second programming assignment, v1