code for the week 3 lecture