r/Clojure • u/LelouBil • 2h ago
Looking for feedback on the first Advent of Code puzzle
Hi, this year I'm doing advent of code in Clojure, because the language looked interesting. I'm completely new to it, but I have done some Haskell before.
Here's my repo https://github.com/LelouBil/advent-of-code-2026
I am not sure if the code can be reduced/simplified further, or if the scaffolding in main (to run different days easily) could be improved.
5
Upvotes
2
u/demosthenex 2h ago
Day one was 2 one-liners. Look at the standard frequencies function, sort and take.
2
u/1234pixel 1h ago
Some useful core functions as well as
frequenciesyou might like to add to your toolkit of you've not seen them:second(forsort-by)take-last(for your inverse)apply(an alternative for that reduce)Sorry about the bad mobile formatting!
2
u/camdez 1h ago
Here are just a few quick notes to get you started:
defrecord. You almost definitely shouldn't use it during AoC problems if you want to learn the Clojure way. Use a map, maaaaybe use a record later for something performance-sensitive.getfunction used.(get coll 0)is(first coll).(get coll 1)is(second coll).(get coll 42)is(nth coll 42).