Solution for problem 97