first attempt on hw2 problem 1