checking out 2020

master
Clyne 3 years ago
parent 140fc0f361
commit d1bb4af495

@ -0,0 +1,9 @@
(require 'clojure.set)
(->> (slurp "./in")
clojure.string/split-lines
(map read-string)
((juxt set (comp set #(map (partial - 2020) %))))
(apply clojure.set/intersection)
(apply *)
(println))

@ -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))
Loading…
Cancel
Save