this repo has no description

D1P2: Slightly Less Bad Solution

+24 -15
+24 -15
src/aoc2025/day1.clj
··· 23 (filter zero?) 24 count)) 25 26 - (defn part2 27 - "This does not work" 28 [rot-seq] 29 - (let [steps (->> rot-seq 30 - (map (partial apply *)) 31 - (reductions (fn [a b] (modwrap (+ a b) 100)) 50))] 32 - (->> steps 33 - util/pairs 34 - (map #(apply compare %)) 35 - (map (fn [[direction _] diff] (vector direction diff)) 36 - rot-seq) 37 - (filter #(apply = %)) 38 - count))) 39 - 40 (defn part2-bad-solution 41 "This is a bad and slow solution but it works" 42 [rot-seq] ··· 50 ([fname] 51 (->> fname 52 parse-file 53 - ((juxt part1 part2-bad-solution))))) 54 55 - (solve "01-test.txt") ; => [3 6]
··· 23 (filter zero?) 24 count)) 25 26 + (defn- zero-passes-reference [dial [direction distance]] 27 + (let [unwrapped-new-dial (+ dial (* direction distance))] 28 + (count (for [n (range dial unwrapped-new-dial direction) 29 + :when (zero? (mod n 100))] 30 + n)))) 31 + 32 + (defn part2-marginally-less-bad-solution 33 + "This does work and isn't horrifically slow but it's a bad solution still" 34 [rot-seq] 35 + (loop [[[direction distance :as current-rotation] & rest-rotations] rot-seq 36 + dial-value 50 37 + zero-count 0] 38 + (if current-rotation 39 + (let [unwrapped-new-dial (+ dial-value (* direction distance)) 40 + 41 + zero-passes-r (zero-passes-reference dial-value current-rotation)] 42 + (recur 43 + rest-rotations 44 + (modwrap unwrapped-new-dial 100) 45 + (+ zero-count zero-passes-r))) 46 + zero-count))) 47 + 48 (defn part2-bad-solution 49 "This is a bad and slow solution but it works" 50 [rot-seq] ··· 58 ([fname] 59 (->> fname 60 parse-file 61 + ((juxt part1 part2-marginally-less-bad-solution))))) 62 63 + (solve "01-test.txt") ;=> [3 6] 64 + (solve) ; => [1089 6530]