adventofcode

maleghast 2025-12-03T18:10:30.653559Z

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?

Apple 2025-12-03T19:04:21.566679Z

show your code.

maleghast 2025-12-03T19:05:52.192059Z

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.

maleghast 2025-12-03T19:07:02.203629Z

However, the brief says “(You cannot rearrange batteries.)”

maleghast 2025-12-03T19:09:54.677769Z

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?

2025-12-03T19:14:05.032259Z

You’re free to do whatever it takes to solve the problem

maleghast 2025-12-03T19:14:14.276229Z

Thx

2025-12-03T19:14:26.105999Z

But I think you misunderstand the instruction 😄

2025-12-03T19:14:32.947219Z

I did too at first

maleghast 2025-12-03T19:15:13.892369Z

I think that I did too - it would appear that the way it is briefed is purposefully opaque.

2025-12-03T19:15:36.109689Z

It means that when you have e.g.

18129
89 is the correct answer, you can’t re-arrange to 98

2025-12-03T19:15:49.123279Z

That also means you can’t sort it and take 2

Apple 2025-12-03T19:16:45.628029Z

(->> (map int xs) (sort >) (take 12)) exactly

maleghast 2025-12-03T19:16:45.843889Z

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?

Apple 2025-12-03T19:18:19.317699Z

part 2 is turning on 12

maleghast 2025-12-03T19:18:39.104849Z

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.

2025-12-03T19:19:54.484879Z

It’s hardware, the batteries are screwed to the bank, you don’t have a screwdriver -> you can’t re-arrange 🤷

maleghast 2025-12-03T19:20:53.758809Z

OK, but why is the output “joltage” the two integers smashed together, why are they not mathematically additive?

2025-12-03T19:21:32.915559Z

Damn, you got me there 😄

maleghast 2025-12-03T19:22:01.845289Z

Right, this is my point. It is pointlessly as well as illogically contrived.

Apple 2025-12-03T19:22:02.581819Z

they are wired to amplifiers in sequence.

maleghast 2025-12-03T19:22:26.602359Z

What, each battery?

Apple 2025-12-03T19:22:34.397349Z

yeah the turned on ones

maleghast 2025-12-03T19:22:34.526729Z

That’s not how batteries work

maleghast 2025-12-03T19:24:42.363919Z

I mean I get that it could be weird-santa-workshop magic, but c’mon…

maleghast 2025-12-03T19:28:17.742769Z

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.

Sam Ferrell 2025-12-03T20:21:05.972079Z

Its the North Pole, things work a little bit differently there

2025-12-03T21:02:21.884819Z

Ah yes, the magnetic field's weird up there

maleghast 2025-12-03T21:02:39.454439Z

facepalm

narimiran 2025-12-04T04:42:07.691979Z

@maleghast Are you joking all along or just taking all this too seriously?

narimiran 2025-12-04T04:47:05.661009Z

Cause, y'know, it's all fiction: there's no Santa.

🤯 1
maleghast 2025-12-04T13:07:58.589149Z

@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.

maleghast 2025-12-04T13:09:28.425679Z

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.

hlship 2025-12-04T22:54:12.810159Z

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.

☝️ 1
hlship 2025-12-04T22:55:20.369759Z

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.

🙌 1
mkvlr 2025-12-03T03:09:08.689929Z

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 @elkenhttps://elken.github.io/aoc/ or @alex.shulginhttps://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.

👍 2
🎉 2
2025-12-03T05:51:22.513959Z

Day 3 - Solutions

snyssfx 2025-12-03T08:08:33.079319Z

not sure it was worth it, but I pass each line only once. Also not sure how to do it without the loop op 🤷‍♂️

Maravedis 2025-12-03T08:11:50.799009Z

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.

🤯 2
Maravedis 2025-12-03T08:12:53.343419Z

I'll probably make a more concise version tonight for my github, I can't commit this, it hurts my soul 😂

Casey 2025-12-03T08:23:01.042479Z

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

jurjanpaul 2025-12-03T09:12:40.768769Z

On my phone (after getting the correct answers I spent too much time attempting to get rid of repeated comparisons and failed): https://jurjanpaul.github.io/ape-cljs-playground/?code=KGRlZiBpbnB1dAogIDs7IHRvIGJlIHJlcGxhY2VkIHdpdGggcmVhbCBpbnB1dAogICI5ODc2NTQzMjExMTExMTEKODExMTExMTExMTExMTE5CjIzNDIzNDIzNDIzNDI3OAo4MTgxODE5MTExMTIxMTEiKQoKKGRlZm4gcGFyc2UgCiAgW2lucHV0XQogICgtPj4gKHN0cmluZy9zcGxpdC1saW5lcyBpbnB1dCkKICAgICAgIChtYXAgIyhtYXAgcGFyc2UtbG9uZyAlKSkpKQoKKGRlZm4gam9sdGFnZQogIFtuIGJhbmtdCiAgKGxvb3AgW24gbgogICAgICAgICBbZGlnaXQgJiBfIDphcyByZW1haW5pbmctYmFua10gYmFuawogICAgICAgICBbbWF4LWRpZ2l0IGJhbmstYWZ0ZXItbWF4XSBbLTEgbmlsXQogICAgICAgICBqIDBdCiAgICAoY29uZCAKICAgICAgKHplcm8%2FIG4pCiAgICAgIGoKICAgICAgKDw9IG4gKGNvdW50IHJlbWFpbmluZy1iYW5rKSkKICAgICAgKHJlY3VyIG4KICAgICAgICAgICAgIChuZXh0IHJlbWFpbmluZy1iYW5rKQogICAgICAgICAgICAgKGlmICg%2BIGRpZ2l0IG1heC1kaWdpdCkKICAgICAgICAgICAgICAgW2RpZ2l0IChuZXh0IHJlbWFpbmluZy1iYW5rKV0KICAgICAgICAgICAgICAgW21heC1kaWdpdCBiYW5rLWFmdGVyLW1heF0pCiAgICAgICAgICAgICBqKQogICAgICA6ZWxzZQogICAgICAocmVjdXIgKGRlYyBuKQogICAgICAgICAgICAgYmFuay1hZnRlci1tYXgKICAgICAgICAgICAgIFstMSBuaWxdCiAgICAgICAgICAgICAoKyAoKiAxMCBqKSBtYXgtZGlnaXQpKSkpKQoKKGRlZiBwYXJzZWQgCiAgKHBhcnNlIGlucHV0KSkKCihkZWZuIHBhcnQxIFtdCiAgKC0%2BPiBwYXJzZWQKICAgICAgIChtYXAgKHBhcnRpYWwgam9sdGFnZSAyKSkKICAgICAgIChyZWR1Y2UgKykpKQoKKHByaW50bG4gInBhcnQxOiIgKHBhcnQxKSkKCihkZWZuIHBhcnQyIFtdCiAgKC0%2BPiBwYXJzZWQKICAgICAgIChtYXAgKHBhcnRpYWwgam9sdGFnZSAxMikpCiAgICAgICAocmVkdWNlICspKSkKCihwcmludGxuICJwYXJ0MjoiIChwYXJ0MikpCg%3D%3D&checksum=OTg4MzY5MjY%3D

benoit 2025-12-03T11:42:34.095779Z

Part2 was easy to guess today 🙂 https://github.com/benfle/advent-of-code/blob/main/src/advent_of_code/2025/03.clj

narimiran 2025-12-03T15:31:39.380789Z

Day 3 notebook: https://narimiran.github.io/aoc2025/src/day03/

Logan Turner 2025-12-03T17:32:56.303969Z

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))

narimiran 2025-12-03T17:49:01.797389Z

Quickly skimming through the solutions posted here.... Nice to see many different approaches!

Maravedis 2025-12-03T18:39:20.268019Z

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

thomas 2025-12-03T20:10:16.561229Z

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.

narimiran 2025-12-04T04:50:19.011199Z

@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)

👍 1
Karl Xaver 2025-12-04T07:55:37.957149Z

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")))
;; => 175659236361660

Andrew Byala 2025-12-03T06:34:33.958619Z

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.mdhttps://github.com/abyala/advent-2025-clojure/blob/main/src/advent_2025_clojure/day03.clj

😎 1
Mateusz Mazurczak 2025-12-10T14:08:03.179029Z

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