Smarter solution for problem 35
Adding solution for problem 37