PA2 Solution for Coursera