Compare commits

..

No commits in common. "bdd2a032301e846b5bfc2ffe6a9dca0047ee7ea2" and "5ef8f4af1d618bf8f895fa070cc32a984a7094bd" have entirely different histories.

2 changed files with 5 additions and 65 deletions

View File

@ -3,6 +3,8 @@
[helpers :refer [get-input]]))
(def test-map
(mapped-area/parse-elements
(mapped-area/read-mapped-area
"89010123
78121874
87430965
@ -10,19 +12,7 @@
45678903
32019012
01329801
10456732")
;(def test-map
;"0123
;1234
;8765
;9876")
(def input
(->
test-map
mapped-area/read-mapped-area
mapped-area/parse-elements))
10456732")))
(defn trailheads [a]
(reduce
@ -52,15 +42,6 @@
(count positions)
(recur (mapcat (partial step a) (set positions))))))
(loop [i 0 positions (trailheads input)]
(println "iteration" i)
(doall
(map #(println % "-" (get-in input %)) positions))
(if (== i 9)
positions
(recur (inc i)
(mapcat (partial step input) positions))))
(trailheads input)
(mapcat (partial step input) (trailheads input))
(reduce +
(map (partial walk test-map) (trailheads test-map)))

View File

@ -1,41 +0,0 @@
(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!"))