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]] (ns day18 (:require [clojure.string :as str]
[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 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 hex-dir {\0 \R, \1 \D, \2 \L, \3 \U})
(def input (->> (get-puzzle-input 18) (def input (->> (get-puzzle-input 18)
(map #(let [[dir n hex-str] (str/split % #" ")] (map #(str/split % #" "))
[(dir-map (last dir)) (map (partial apply-each-v
(parse-long n) (comp> last dir-map)
[(-> hex-str drop-last last hex-dir dir-map) parse-long
(-> hex-str (juxt (comp> drop-last last hex-dir dir-map)
(subs 2 (- (count hex-str) 2)) #(-> (subs % 2 (- (count %) 2))
(Long/parseLong 16))]])))) (Long/parseLong 16)))))))
;; Shoelace / Pick's Algorithm, wtf?! ;; Shoelace / Pick's Algorithm, wtf?!
(defn area [vs] (defn area [vs]