Skip to content

Instantly share code, notes, and snippets.

@Heliosmaster
Created December 6, 2020 08:31
Show Gist options
  • Save Heliosmaster/fe7981021eefe0b53e31787be4c1d6c2 to your computer and use it in GitHub Desktop.
Save Heliosmaster/fe7981021eefe0b53e31787be4c1d6c2 to your computer and use it in GitHub Desktop.
(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