Wrote a bit of problem2 in hw3.