Skip to content

Instantly share code, notes, and snippets.

@quoll
Last active January 26, 2018 04:36
Show Gist options
  • Save quoll/b3f1d289358435e5d76268c14228f9ce to your computer and use it in GitHub Desktop.
Save quoll/b3f1d289358435e5d76268c14228f9ce to your computer and use it in GitHub Desktop.
(defn day3* [input]
(loop [i 2 mem [1 1]]
(let [[x y] (coords i)
v (apply + (for [p [-1 0 1] q [-1 0 1]
:let [f (offset (+ x p) (+ y q))]
:when (< f i)]
(get mem f)))]
(if (> v input)
v
(recur (inc i) (conj mem v))))))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment