Adding solution to problem 17