Compare commits

...

2 Commits

Author SHA1 Message Date
7f4c260855 do day3 2025-12-04 11:06:46 -10:00
6306a76b7e remove unused dep 2025-12-04 11:04:17 -10:00
2 changed files with 27 additions and 2 deletions

View File

@ -1,6 +1,5 @@
(ns day01 (ns day01
(:require input-manager (:require input-manager))
#_[clojure.string :as str]))
(defn parse-line [line] (defn parse-line [line]
[(.charAt line 0) [(.charAt line 0)

26
2025/src/day03.clj Normal file
View File

@ -0,0 +1,26 @@
(ns day03
(:require input-manager))
(def input (input-manager/get-input 2025 3))
(defn max-joltage [bank num-batteries-to-activate]
(let [len (count bank)]
(loop [n num-batteries-to-activate
acc ""
idx-iter 0]
(let [search-space (.substring bank idx-iter (- len (dec n)))
max-char (apply max (map int search-space))
max-char-idx (.indexOf bank max-char idx-iter)]
(if (= n 1)
(parse-long (str acc (char max-char)))
(recur (dec n)
(str acc (char max-char))
(inc max-char-idx)))))))
(->> input
(map #(max-joltage % 2))
(apply +))
(->> input
(map #(max-joltage % 12))
(apply +))