Exercise 2 from Week 4 homework.