diff options
author | Clyne Sullivan <clyne@bitgloo.com> | 2021-12-15 12:03:47 -0500 |
---|---|---|
committer | Clyne Sullivan <clyne@bitgloo.com> | 2021-12-15 12:03:47 -0500 |
commit | aed41aa1f74252bb8a14f1750c2a6f27916795c8 (patch) | |
tree | f22bb8d5954d9a7ba1a162a33e08140b695c5810 /year2020/day1/part2.clj | |
parent | 453a97b8133c72490785dbc48e68d2dd102974f8 (diff) | |
parent | d1bb4af495094eec997cbe7e99a382877c7c7b5a (diff) |
add day 15
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)) |