initial try at hw2 prob 3 and 4