You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

21 lines
493 B
Clojure

(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))