Doubled performnance of problem 74 with better memoizing