add solutions to problem 38, 39, 40, but need cleanup