Problem 31 solution added. ~0.06 seconds running time.