Finished homework for week 4 (Part I & II)