homework 3.2 for cs184