problem 9 working with example input