Solution to Programming Assignment 2