added solution to prob40