Week 3, Course 5, Programming Assignment 1

The answer is given in this thread.