This commit is contained in:
Adam Jeniski 2023-12-04 01:22:00 -05:00
parent b38a9393d3
commit cf53738987

View File

@ -6,10 +6,7 @@
[clojure.string :as string]
[core :refer [get-puzzle-input]]))
(def lines (get-puzzle-input 4))
(defn parse-lines [lines]
(->> lines
(def data (->> (get-puzzle-input 4)
(map #(rest (re-find #"^Card\s*\d+: ([\s\d]+) \| ([\s\d]+)" %)))
(map (partial map #(->> (string/split % #" ")
(filter not-empty)
@ -17,7 +14,7 @@
(into #{}))))))
;; part 1
(->> (parse-lines lines)
(->> data
(map (partial apply intersection))
(map count)
(map #(math/pow 2 (dec %)))
@ -26,7 +23,7 @@
;; part 2
(loop [acc 0
data (->> (parse-lines lines)
data (->> data
(map #(vector 1 (count (apply intersection %))))
(into []))]
(if (not-empty data)