do day 11

This commit is contained in:
Adam Jeniski
2026-05-15 09:27:43 -04:00
parent 0aed472a32
commit e6357d9802
+27
View File
@@ -0,0 +1,27 @@
(ns day11
(:require [core]
input-manager
[clojure.string :as str]))
(def input (-> (input-manager/get-input-raw 2017 11)
(str/split #",")))
(def offsets {"n" [0 1]
"ne" [0.5 0.5]
"se" [0.5 -0.5]
"s" [0 -1]
"sw" [-0.5 -0.5]
"nw" [-0.5 0.5]})
(defn distance-from-origin [pos]
(let [[x y] (map abs pos)]
(+ (* x 2) (- y x))))
(->> input
(map offsets)
(reductions #(map + %1 %2) [0 0])
(map distance-from-origin)
((juxt last (partial apply max)))
(zipmap [:part-one :part-two]))