Solution for problem 118