added solution for hw2 problem 1d