Skip to content

Instantly share code, notes, and snippets.

@dilbernd
Created January 15, 2020 00:43
Show Gist options
  • Select an option

  • Save dilbernd/83bb70d462656fd663a0cccf5aec9c39 to your computer and use it in GitHub Desktop.

Select an option

Save dilbernd/83bb70d462656fd663a0cccf5aec9c39 to your computer and use it in GitHub Desktop.
(def inputs [...])
(def day2_2_sought 42)
(defn computer [data ip]
(let [[op oa1 oa2 t] (subvec data ip)
o1 (data oa1)
o2 (data oa2)
ofn ({1 + 2 * 99 :hlt} op)]
(if (= :hlt ofn) (data 0) (recur (assoc data t (ofn o1 o2)) (+ 4 ip)))))
(first (for [x (range 100) y (range 100) :when (= day2_2_sought (computer (assoc inputs 1 x 2 y) 0))] (+ (* 100 x) y)))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment