Solve gradient descent exercise.