mirror of
https://github.com/Ajetski/advent-of-code.git
synced 2025-09-30 09:23:17 -09:00
golf
This commit is contained in:
parent
7eb6fd4f57
commit
752aa3f640
@ -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]
|
||||
|
Loading…
x
Reference in New Issue
Block a user