   "The maximal weight possible. To be rebound.")
 
 (defn- titanic-closure
-  ""
+  "Computes the closure of X by the weights of its subsets."
   [X base-set key-set candidates]
   (let [Y (apply union X (map #(closure (disj X %)) X))]
     (loop [Y Y,

        (let [m   (first elements),
              X+m (conj X m),
              s   (if (contains? candidates X+m)
                    (set-weight X+m)
                    (minimum (for [K key-set,
                                   :when (subset? K X+m)]
                               (set-weight K))))]
          (recur (if (= s (set-weight X))
                   (conj Y m)
                   Y)
                 (rest elements)))

      (let [empty-weight (set-weight #{})]
        (doseq [m base-set]
          (set-val! subset-weight #{m} empty-weight)))
      (loop [key-set    #{#{}},
             candidates (set-of #{m} [m base-set]),
             key-sets   [key-set]]
        (set! set-weight (into set-weight (weigh candidates)))
        (doseq [X key-set]
          (set-val! closure X (titanic-closure X base-set key-set candidates)))
        (let [next-key-set (set-of X [X candidates,
                                      :when (not= (get subset-weight X max-weight)
                                            (get set-weight X max-weight))])]
          (if-not (empty? next-key-set)
            (recur next-key-set
                   (titanic-generate next-key-set)
                   (conj key-sets next-key-set))
            (distinct (mapcat #(map closure %) key-sets))))))))


