               assoc-remaining-work
               {}
               working)
+            dependencies
             d-parents
             rdy')]
     v))


(defn assoc-remaining-work
  [d c]
  (let [v (-> c first int (- 4))]
    (assoc c v)))

(defn count-seconds
  [ttl rw-count

   ready]
  (println "==== rw-count ====")
  (println rw-count)
  (println "==== deps ====")
  (clojure.pprint/pprint deps)
  (println "==== working ====")
  (println working)
  (println "==== finished ====")
  (prn finished)
  (println "==== ready ====")
  (println ready)
  (if (and (empty? ready) (empty? working))
    ttl
    (let [dt (apply min (map second working))
          [w' df'] (reduce
                     (fn [[d f] [k v]]
                       (if (zero? (- v dt))
                         [(dissoc d k) (conj f k)]
                         [(assoc d k (- v dt)) f]))
                     [{} #{}]
                     working)
          f' (apply conj finished df')
