diff options
Diffstat (limited to 'year2020/day1/part2.clj')
-rw-r--r-- | year2020/day1/part2.clj | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/year2020/day1/part2.clj b/year2020/day1/part2.clj new file mode 100644 index 0000000..0b6ef9d --- /dev/null +++ b/year2020/day1/part2.clj @@ -0,0 +1,20 @@ +(require 'clojure.set) + +(defn find-sum [sum lst] + (->> lst + ((juxt set (comp set #(map (partial - sum) %)))) + (apply clojure.set/intersection) + (vec))) + +(->> (slurp "./in") + clojure.string/split-lines + ((comp set (partial map read-string))) + ((fn [lst] + (reduce + #(let [fnd (find-sum (- 2020 %2) (clojure.set/difference lst #{%2}))] + (if (empty? fnd) %1 [%2 fnd])) + [] + lst))) + flatten + (apply *) + (println)) |