Solve the challenge case of Problem 9