Last active
January 26, 2018 03:59
-
-
Save quoll/ea45814beacc8aed697245d91f3eb1a2 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(defn day3* [input] | |
(loop [i 2 field (init fieldr)] | |
(let [[x y] (coords i) | |
x' (+ fieldr x) | |
y' (+ fieldr y) | |
v (apply + (for [p [-1 0 1] q [-1 0 1] :when (not (= 0 p q))] | |
(get-in field [(+ y' q) (+ x' p)])))] | |
(if (> v input) | |
v | |
(recur (inc i) (assoc-in field [y' x'] v)))))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment