diff --git a/2023/src/day18.clj b/2023/src/day18.clj index 0029a0d..5afc22f 100644 --- a/2023/src/day18.clj +++ b/2023/src/day18.clj @@ -1,17 +1,17 @@ -(ns day18 (:require [core :refer [get-puzzle-input]] - [clojure.string :as str])) +(ns day18 (:require [clojure.string :as str] + [core :refer [apply-each-v comp> get-puzzle-input]])) (def dir-map {\U [-1 0], \L [0 -1], \R [0 1], \D [1 0]}) (def hex-dir {\0 \R, \1 \D, \2 \L, \3 \U}) (def input (->> (get-puzzle-input 18) - (map #(let [[dir n hex-str] (str/split % #" ")] - [(dir-map (last dir)) - (parse-long n) - [(-> hex-str drop-last last hex-dir dir-map) - (-> hex-str - (subs 2 (- (count hex-str) 2)) - (Long/parseLong 16))]])))) + (map #(str/split % #" ")) + (map (partial apply-each-v + (comp> last dir-map) + parse-long + (juxt (comp> drop-last last hex-dir dir-map) + #(-> (subs % 2 (- (count %) 2)) + (Long/parseLong 16))))))) ;; Shoelace / Pick's Algorithm, wtf?! (defn area [vs]