Finish Problem 2 with test cases