Complete assignment 2 from https://class.coursera.org/rprog-007