diff --git a/src/day11.clj b/src/day11.clj new file mode 100644 index 0000000..1cbdb38 --- /dev/null +++ b/src/day11.clj @@ -0,0 +1,41 @@ +(ns day11 + (:require [clojure.string :as string] + [helpers :refer [get-input]])) + +(def stones + (string/split + ;;"125 17" + (string/trim (get-input 11)) + #" ")) + +(defn split-stone [stone] + (let [ss (split-at + (/ (count stone) 2) + stone) + seq->stone + (fn [s] + (str + (parse-long + (apply str s))))] + (mapv seq->stone ss))) + +(defn blink [stone] + (cond + (= stone "0") + ["1"] + (even? (count stone)) + (split-stone stone) + :else + (vector + (str + (* 2024 + (parse-long stone)))))) + +(time + (println "I blinked 25 times, there's" + (count + (loop [i 0 stones stones] + (if (= 25 i) + stones + (recur (inc i) (mapcat blink stones))))) + "stones!"))