Solution for problem 19