(ns adventofcode2019.day06 [:require [adventofcode2019.lib :refer :all] [clojure.string :as str]]) ;; FIXME: is the input guaranteed in-order? (defn a-orbits-b [orbits-map [b a]] (if (contains? orbits-map b) (-> (assoc orbits-map a {:parent b, :children [], :depth (inc (:depth b))}) (update-in [b :children] conj a)) (-> (assoc orbits-map b {:parent nil, :children [], :depth 0}) (a-orbits-b [b a])))) (defn day06 [] (let [input (map #(str/split % #")") (get-list-from-file (input-file))) orbits-map (reduce a-orbits-b {} input)] (part1 (reduce + (map :depth orbits-map))) #_(part2)))