Programming exercise in https://class.coursera.org/ml-006/