ref: 3703478dcfedd048437f7a0515dbda2ff8a22d8d
src/aoc/day06.clj
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 |
(ns aoc.day06 (:require [clojure.java.io :as io])) (def example "abc a b c ab ac a a a a b") (defn group-said-yes [group] (apply clojure.set/union (map set group))) (defn group-all-said-yes [group] (apply clojure.set/intersection (map set group))) ;; ---- (defn read-input [] (->> (clojure.string/split (slurp (io/resource "input06.txt")) #"\n\n") (map clojure.string/split-lines))) (defn compute-1 [input] (->> input (map group-said-yes) (map count) (apply +)) ) (defn compute-2 [input] (->> input (map group-all-said-yes) (map count) (apply +))) (defn main [] (let [input (read-input)] (println (compute-1 input)) (println (compute-2 input)))) (main) |