diff --git a/2017/src/day11.clj b/2017/src/day11.clj new file mode 100644 index 0000000..9da0e5c --- /dev/null +++ b/2017/src/day11.clj @@ -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])) +