homework 3.1 for cs184