This commit is contained in:
Adam Jeniski 2023-12-18 21:57:56 -05:00
parent 7eb6fd4f57
commit 752aa3f640

View File

@ -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]