Add solution to problem 18.