Created
December 6, 2020 08:31
-
-
Save Heliosmaster/fe7981021eefe0b53e31787be4c1d6c2 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(require '[clojure.string :as str]) | |
(def example "abc\n\na\nb\nc\n\nab\nac\n\na\na\na\na\n\nb") | |
(defn part-1 [a] | |
(->> (str/split a #"\n\n") | |
(map #(str/replace % #"\n" "")) | |
(map set) | |
(map count) | |
(reduce +))) | |
(part-1 (slurp "./inputs/day6.txt")) | |
(defn part-2 [a] | |
(->> (str/split a #"\n\n") | |
(map #(str/split % #"\n")) | |
(map (fn [answers] | |
(apply clojure.set/intersection (map set answers)))) | |
(map count) | |
(reduce +))) | |
(part-2 (slurp "./inputs/day6.txt")) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment