Problem 40 solved