use better names

This commit is contained in:
Adam Jeniski 2023-12-02 01:19:36 -05:00
parent f8d81983cd
commit 20539f6005

View File

@ -19,24 +19,28 @@
;; part 1 ;; part 1
(->> lines (->> lines
(filter (fn [[_id states]] (filter
(not (some (fn [[_id games]]
#(some (fn [[cnt color]] (not (some (fn [game]
(< (cube-counts color) cnt)) %) (some (fn [[cnt color]]
states)))) (< (cube-counts color) cnt))
game))
games))))
(map (fn [[id]] (Integer/parseInt id))) (map (fn [[id]] (Integer/parseInt id)))
(reduce +)) (reduce +))
;; part 2 ;; part 2
(->> lines (->> lines
(map (fn [[_id states]] (map (fn [[_id games]]
(reduce #(reduce (fn [acc [cnt color]] (reduce (fn [acc game]
(update acc color max cnt)) (reduce (fn [inner-acc [cnt color]]
%1 (update inner-acc color max cnt))
%2) acc
game))
{"green" 0, "red" 0, "blue" 0} {"green" 0, "red" 0, "blue" 0}
states))) games)))
(map #(* (% "green") (map #(* (% "green")
(% "red") (% "red")
(% "blue"))) (% "blue")))
(reduce +)) (reduce +))