   [base-set weigh max-weight weight-minimum]
   (binding [closure       {},
             set-weight    (weigh [#{}]),
-            subset-weight (memoize (partial subset-weight max-weight)),
+            subset-weight (partial subset-weight max-weight),
             minimum       weight-minimum]
 
     (loop [key-set    #{#{}},

                                                (get set-weight X))])]
        (if-not (empty? next-key-set)
          (recur next-key-set
                 (titanic-generate next-key-set)
                 (sort (fn [a b]
                         (= (get set-weight a)
                            (weight-minimum [(get set-weight a) (get set-weight b)])))

                 max-weight)))

(defn- titanic-closure
  "Computes the closure of X by the weights of its subsets. The
  following restrictions apply:

    - keys is the sequence of already computed key sets and is orderd
      by weights ascending,
    - X is a member of keys.
  "
  [X base-set keys candidates]
  (let [X-weight (set-weight X),
        keys     (map #(vector % (set-weight %)) keys)]
    (loop [Y        (apply union X (map #(closure (disj X %)) X)),
           elements (difference base-set Y)]
      (if-not (empty? elements)
        (let [m    (first elements),
              add? (if-let [s (set-weight (conj X m))]
                     (= s X-weight)
                     (not (first (for [[K weight] keys,
                                       :while (not= weight X-weight)
                                       :when (and (contains? K m)
                                                  (subset? (disj K m) X))]
                                   K))))]
          (recur (if add? (conj Y m) Y)
                 (rest elements)))
        Y))))

(defn- titanic-generate
  "Computes the next candidate set."
  [base-set key-set]
  (set-of next [A key-set,
                m (difference base-set A),
                :let [next (conj A m)]
                :when (forall [x A]
                        (contains? key-set (disj next x)))]))

(defn titanic
  "Implements the titanic algorithm. weigh must return for a
