Add memoize(), use it for solve() by creating memoizingSolve()