Faster solutions for problem 36.