1 (ns adventofcode2019.day08
2 [:require [adventofcode2019.lib :refer :all]
3 [clojure.core.match :refer [match]]])
6 "Binary operation on the pixels of two layers, the first above the second."
13 (let [input (mapv parse-int (get-list-from-file (input-file) #""))
15 count-num #(count (filter (hash-set %1) %2))
16 layers (partition layer-size input)
17 fewest-zeroes (apply (partial min-key (partial count-num 0))
19 layered-image (reduce #(mapv combine-layers %1 %2) layers)
20 to-ascii #(match % 0 \u0020 ; 0s are spaces, 1s are full-block
22 (part1 (* (count-num 1 fewest-zeroes)
23 (count-num 2 fewest-zeroes)))
25 (run! println (partition 25 (map to-ascii layered-image)))))