Skip to content

Instantly share code, notes, and snippets.

@quoll
Last active January 26, 2018 03:59
Show Gist options
  • Save quoll/ea45814beacc8aed697245d91f3eb1a2 to your computer and use it in GitHub Desktop.
Save quoll/ea45814beacc8aed697245d91f3eb1a2 to your computer and use it in GitHub Desktop.
(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