Memoized Clojure solution