Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- (ns day02
- (:require [clojure.string :as str]))
- (def input
- (into [] (map read-string
- (-> "input.txt"
- (slurp)
- (str/split #",")))))
- (let [ints (atom input)]
- (loop [i 0]
- (case (nth @ints i)
- 1 (swap! ints assoc (nth @ints (+ i 3))
- (+ (nth @ints (nth @ints (+ i 1)))
- (nth @ints (nth @ints (+ i 2)))))
- 2 (swap! ints assoc (nth @ints (+ i 3))
- (* (nth @ints (nth @ints (+ i 1)))
- (nth @ints (nth @ints (+ i 2)))))
- 99 (println "Program complete:" @ints)
- (println "Something went wrong"))
- (if (>= i (- (count @ints) 1))
- (println "Solution:" (nth @ints 0))
- (if (< 4 (- (count @ints) i))
- (recur (+ i 4))))))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement