From 20539f60057cceda077e94bdad62e35c7b4601aa Mon Sep 17 00:00:00 2001 From: Adam Jeniski Date: Sat, 2 Dec 2023 01:19:36 -0500 Subject: [PATCH] use better names --- 2023/src/day02.clj | 26 +++++++++++++++----------- 1 file changed, 15 insertions(+), 11 deletions(-) diff --git a/2023/src/day02.clj b/2023/src/day02.clj index bf32045..f59247c 100644 --- a/2023/src/day02.clj +++ b/2023/src/day02.clj @@ -19,24 +19,28 @@ ;; part 1 (->> lines - (filter (fn [[_id states]] - (not (some - #(some (fn [[cnt color]] - (< (cube-counts color) cnt)) %) - states)))) + (filter + (fn [[_id games]] + (not (some (fn [game] + (some (fn [[cnt color]] + (< (cube-counts color) cnt)) + game)) + games)))) (map (fn [[id]] (Integer/parseInt id))) (reduce +)) ;; part 2 (->> lines - (map (fn [[_id states]] - (reduce #(reduce (fn [acc [cnt color]] - (update acc color max cnt)) - %1 - %2) + (map (fn [[_id games]] + (reduce (fn [acc game] + (reduce (fn [inner-acc [cnt color]] + (update inner-acc color max cnt)) + acc + game)) {"green" 0, "red" 0, "blue" 0} - states))) + games))) (map #(* (% "green") (% "red") (% "blue"))) (reduce +)) +