mirror of
https://github.com/Ajetski/advent-of-code.git
synced 2025-09-30 09:23:17 -09:00
use better names
This commit is contained in:
parent
f8d81983cd
commit
20539f6005
@ -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 +))
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user