fasten using memoize at problem 074