add test and solution for problem 39 (problem 38 is not a real problem)