problem 9 solution in swift