turned problem 2 into a function
added a test for problem 2
reform mated this test