answers for hmwk 3, decent solution for problem 6