Solution to week 3 assignment