do day 11
This commit is contained in:
@@ -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]))
|
||||
|
||||
Reference in New Issue
Block a user