I realise that the Day 3 puzzle says that I can’t rearrange the batteries in each bank, but why can’t my script rearrange them notionally for me so that I can find the max joltage for each bank? I mean is it just that doing so just makes it too easy?
show your code.
I haven’t started yet. It seems obvious to me that if one is going to write code to solve the problem then there is no reason to not take the input data and rearrange it to get the answer easily.
However, the brief says “(You cannot rearrange batteries.)”
Why can’t I? I am using a computer to solve the problem, why can’t I copy down the details of the various banks (download the data) and using code rearrange the banks programmatically to find the highest values in each bank and thereby solve the task?
You’re free to do whatever it takes to solve the problem
Thx
But I think you misunderstand the instruction 😄
I did too at first
I think that I did too - it would appear that the way it is briefed is purposefully opaque.
It means that when you have e.g.
18129
89 is the correct answer, you can’t re-arrange to 98That also means you can’t sort it and take 2
(->> (map int xs) (sort >) (take 12)) exactly
Yeah, I get that, but the restriction makes NO sense Why would you not turn on the two with the highest value in any order that is most efficacious?
part 2 is turning on 12
Every year I get one to five days / puzzles in only to find that one of the puzzles is purposefully over complicated for no good reason.
It’s hardware, the batteries are screwed to the bank, you don’t have a screwdriver -> you can’t re-arrange 🤷
OK, but why is the output “joltage” the two integers smashed together, why are they not mathematically additive?
Damn, you got me there 😄
Right, this is my point. It is pointlessly as well as illogically contrived.
they are wired to amplifiers in sequence.
What, each battery?
yeah the turned on ones
That’s not how batteries work
I mean I get that it could be weird-santa-workshop magic, but c’mon…
I will still do the puzzle, I reckon, but honestly it’s contrived as all hell. preserving the order of the values from left to right to create an arbitrary number in the way that kids joke that 1+1 = 11 is bonkers.
Its the North Pole, things work a little bit differently there
Ah yes, the magnetic field's weird up there
facepalm
@maleghast Are you joking all along or just taking all this too seriously?
Cause, y'know, it's all fiction: there's no Santa.
@narimiran - I am expressing what I gather is a not uncommon frustration with the contrived nature of the puzzle, that it appears to be structured in such a way as to make it difficult without a sensible, logical reason for the restrictions, and at the same time providing a programming challenge that feels esoteric and unlikely to find a real / commercial use in day to day life as a programmer. This doesn’t mean that I am angry, or against AoC (I’ve taken part for years and am trying to take part this year, I have donated in previous years - this year I am broke and so I haven’t), it is just an expression of my frustration.
To be clear, I am not saying that a lot of people are frustrated with this particular puzzle, I am saying that over the years I have, admittedly anecdotally, noticed a good number of people expressing similar frustrations, as have I before, whilst still being fond of the competition / event as a whole.
Well, I'm glad that they at least treated the Santa, Elves, and secret base at the north pole in an entirely realistic matter, even if they screwed up the details on magic battery selection and alignment.
Part of the fun is picking out the relevant details in the carefully crafted examples. In stage 2 the specific culled batteries in the examples lead me to the simple solution rather than the vastly overcomplicated one I started with.
a little late but I’ve just updated the https://github.com/nextjournal/advent-of-clerk template repo with the latest clerk bits. I think it’s a great way to share your solutions, as you can see in @elken’ https://elken.github.io/aoc/ or @alex.shulgin’ https://github.clerk.garden/a1exsh/advent-of-clerk/commit/45dfdbe672ca2e45a39bd160589e52d4df03f0a7/src/advent_of_clerk/day_12.html. If you’re feeling brave you can even give Clerk + babashka babashka a try. If you run into any issue, please do reach out in #clerk.
Day 3 - Solutions
not sure it was worth it, but I pass each line only once. Also not sure how to do it without the loop op 🤷♂️
At work, didn't have the time to come up with something more elegant. For part 1, remove 10 out of 12 conds, and only repeat the 0 twice in the accumulator.
I'll probably make a more concise version tonight for my github, I can't commit this, it hurts my soul 😂
i had fun with this one, a nice little algo brain teaser, and was pretty lucky in that i chose the generic solution in part 1 https://github.com/Ramblurr/advent-of-code/blob/main/src/aoc/2025/day03.clj
Part2 was easy to guess today 🙂 https://github.com/benfle/advent-of-code/blob/main/src/advent_of_code/2025/03.clj
https://github.com/tschady/advent-of-code/blob/main/src/aoc/2025/d03.clj
fun! https://github.com/FelipeCortez/advent-of-code/blob/master/2025/03.clj
Day 3 notebook: https://narimiran.github.io/aoc2025/src/day03/
New to Advent of Code this year, but part 2 was pretty predictable today. Went for some unoptimized recursion since the stack would only be about as deep as the number of digits.
(ns exercises.advent-2025-12-03
(:require
[clojure.string :as str]))
(defn digits [n]
(map #(Character/getNumericValue %) (str n)))
(defn from-digits [xs]
(parse-long (apply str xs)))
(defn largest-n-digit-seq [n s]
(when (pos? n)
(let [hi (apply max (drop-last (dec n) s))]
(->> (drop-while (complement #{hi}) s)
rest
(largest-n-digit-seq (dec n))
(cons hi)))))
(defn sum-largest-n [n input]
(apply + (for [line (str/split-lines input)]
(->> (digits line)
(largest-n-digit-seq n)
from-digits))))
(defn day-3-part-1 [input]
(sum-largest-n 2 input))
(defn day-3-part-2 [input]
(sum-largest-n 12 input))Quickly skimming through the solutions posted here.... Nice to see many different approaches!
Factorized it a bit. It's less readable, but I can commit this without feeling terrible about it. Full solution + utils: https://github.com/Maravedis/advent_code/tree/master/src/advent_of_code/2025
This is my part 1:
(->> data
(clojure.string/split-lines)
(mapv (fn [a] (mapv #(parse-long (str %)) a)))
(mapv (fn [a] (let [biggest (apply max (drop-last a))
index-of (.indexOf a biggest)
sub (apply max (subvec a (inc index-of)))]
(parse-long (str biggest sub)))) )
(reduce +))
And as it is not a generic one I have no clue how to get to part 2.... food for thought. I had a look at some of your solutions and don't really get it.@thomas That's why I'm writing these notebooks: in hopes that I can explain why and how I'm doing stuff that I'm doing. (And if it is still confusing after reading it, then I failed my job)
Quick and very ugly. Looking forward to study all the elegant solutions so far 🙂
Edit: already found some TILs
• I prefer (complement #{highest})to my (partial not= highest)
• Recursion , ofc!
;; Part 1
(transduce
(comp
(map (fn [bank]
(let [digits (mapv Character/getNumericValue bank)
highest (apply max (butlast digits))]
[highest
(apply max (rest (drop-while (partial not= highest) digits)))])))
(map (partial apply str))
(map parse-long))
+
(str/split-lines (slurp "day3")))
;; => 17694
;; Part 2
(transduce
(comp
(map (fn [bank]
(loop [cnt 11
digits (mapv Character/getNumericValue bank)
res []]
(if (neg? cnt)
res
(let [highest (apply max (drop-last cnt digits))]
(recur (dec cnt)
(rest (drop-while (partial not= highest) digits))
(conj res highest)))))))
(map (partial apply str))
(map parse-long))
+
(str/split-lines (slurp "day3")))
;; => 175659236361660https://gitlab.com/maximoburrito/advent2025/-/blob/main/src/day03/main.clj
https://github.com/samcf/advent-of-code/blob/main/2025-03-lobby.clj
Pretty happy with this one. Good thing the puzzles start to resemble each other year after year! • https://github.com/abyala/advent-2025-clojure/blob/main/docs/day03.md • https://github.com/abyala/advent-2025-clojure/blob/main/src/advent_2025_clojure/day03.clj
https://github.com/brandoncorrea/advent-of-code/blob/master/clojure/src/aoc/y2025/day03.cljc
https://github.com/genmeblog/advent-of-code/blob/master/src/advent_of_code_2025/day03.clj
Life got into the way and had no time to do it the same day 😭 https://mateuszmazurczak.com/aoc/2025/3#solution-7e323e08-7f03-4d10-afc5-980ad35fb37a