r/adventofcode • u/daggerdragon • 20h ago
SOLUTION MEGATHREAD -❄️- 2026 Day 1 Solutions -❄️-
It's that time of year again for tearing your hair out over your code holiday programming joy and aberrant sleep for two weeks helping Santa and his elves! If you participated in a previous year, welcome back, and if you're new this year, we hope you have fun and learn lots!
As always, we're following the same general format as previous years' megathreads, so make sure to read the full posting rules in our community wiki before you post!
RULES FOR POSTING IN SOLUTION MEGATHREADS
If you have any questions, please create your own post in /r/adventofcode with the Help/Question flair and ask!
Above all, remember, AoC is all about learning more about the wonderful world of programming while hopefully having fun!
REMINDERS FOR THIS YEAR
- All of our rules, FAQs, resources, etc. are in our community wiki.
- If you see content in the subreddit or megathreads that violates one of our rules, either inform the user (politely and gently!) or use the report button on the post/comment and the mods will take care of it.
- If you post your code from a repo or the like, do not make your puzzle input public!
- Top-level
Solution Megathreadposts must begin with the case-sensitive string literal[LANGUAGE: xyz] - Obviously,
xyzis the programming language your solution employs - Use the full name of the language e.g.
JavaScriptnot justJS - The List of Streamers has a new megathread for this year's streamers, so if you're interested, add yourself to 📺 AoC 2026 List of Streamers 📺
COMMUNITY NEWS
- Veloxx will continue to drop some lit beats for 1.5 hours after today's unlock!
- /u/jeroenheijmans is back again this year with their Unofficial AoC 2026 Participant Survey!
- Advent of Code Community Fun 2026: The Advent Games
- I will be your master of ceremonies for this year's community fun event: The Advent Games
- Full details, rules, timeline, templates, etc. will be in the Submissions Megathread
(post and link incoming very shortly!) - edit: -❄️- Advent of Code 2026: The Advent Games -❄️- Submissions Megathread -❄️-
AoC Community Fun 2026: The Advent Games
Today's Event: Opening Ceremonies
Today's schedule consists of:
- Arrival of the Flame
- Parade of Nations1
- Give us a quick introduction to yourself!
- Tell us what country you're from
- Tell us about your country's holiday festivities
- Explain why you chose your programming language
- Tell us what you hope to learn or have already learned about your chosen programming language
- Tell us where to find your AoC repo of puzzle solutions2, blag, and/or $streaming_service3!
- Artistic Program
- Show us your holiday tree | menorah | Krampusnacht costume | /r/battlestations with festive decorations!
- Show us your kittens and puppies and $critters!
- Show and/or tell us about whatever brings you comfort and joy in the holiday season!
- Competition Schedule (Theoretical)
- Tell us which "sporting" events you think will be coming up over the next two weeks and which ones you'd like to participate in the most!
1 Obviously, this is the Internet, which is public, so only put out information that you're comfortable with the entire world knowing. Feel free to invent a holiday-themed persona; after all, sometimes you get sent to space, so why limit yourself to the boring ol' meat skeleton that dwells upon the third rock from the sun?
2 Refer to the third bullet in the "Reminders" section above!
3 Refer to the last bullet in the "Reminders" section above for the link
Request from the mods: When you include an entry alongside your solution, please label it with [Advent Games] so we can find it easily!
--- Day 1: Dusty Shed ---
Post your code solution in this megathread.
- Read the full posting rules in our community wiki before you post!
- State which language(s) your solution uses with
[LANGUAGE: xyz] - Format code blocks using the four-spaces Markdown syntax!
- Quick link to Topaz's
pasteif you need it for longer code blocks. What is Topaz'spastetool?
25
u/4HbQ 20h ago edited 9h ago
[LANGUAGE: Python]
Most of the magic happens in line 2. Inside the
sortedcall, we take all unique values from input N by turning them into a set. Then we sort the values in this set by the number of occurrences in the original N, usingseq.count(). Here's an example:On the assignment part of line 2, we use extended iterable unpacking. It allows you to "unpack" a list by assigning individual elements. Here's an example:
This was my initial version (3 lines), using
collections.Counter()like everybody else.10
u/RazarTuk 11h ago edited 11h ago
[LANGUAGE: Perl... in the original Klingon]
[Advent Games]
I'm actually just from the Chicago area and, apart from college, have lived here my whole life. However, my mom's side of the family comes from a part of Indiana with fairly strong German cultural heritage, so I grew up with a lot of that version of Christmas, which I hope to show off.
So it helps for the Americanized German Christmas that I'm, you know, outside of Chicago with our Christkindlmarket, where I'm probably going to go for lunch today to get my annual raclette sandwich. I also grew up celebrating St. Nicholas Day, although we just used stockings instead of the traditional shoes, so it really just amounts to a second stockingful of candy each year. (Although some of my cousins actually do put out shoes for St. Nicholas Day) And then one of the most iconic cookies for me growing up was springerle (shpringerluh, or we Anglicized it to springerlee), which are embossed anise-flavored cookies. If this were a few days from now, I'd have a batch in the works to show off. But for now, all you'll get is the rolling pin. (Expect more pictures over the weekend)
If I'm being honest, the first few days are always easier for experienced programmers, so I like picking a silly language to force myself to focus on basics. For example, this time around, I couldn't get sort to work, so I had to write a quick insertion sort myself. And then I picked Klingon over Latin for 3 reasons. 1) The Latin library is so notoriously buggy that people will tell you to ignore the documentations, 2) I know just enough Latin to be annoyed by how only nearly correct it is, and 3) "in the original Klingon" is an inherently funny phrase.
On the religious side, I have a hybrid Advent wreath / Nativity scene set up. I'm just using LED candles, but the idea is that you light another candle each Sunday leading up to Christmas, with the pink candle being the 3rd Sunday of Advent / 2 Sundays before Christmas. https://imgur.com/a/gB9tT2z Then on the vaguely secular side, I also have an artificial tree up, decorated with Vintaglo lights. And through the magic of buying two
of themboxes, I had enough to cover my tree (although I think I need some practice in spreading them out). https://imgur.com/a/pzEXXfK6
u/Smylers 20h ago edited 12h ago
[LANGUAGE: Bash, with traditional Unix utilities] For Part 1, with your input saved in a file called
input, run:That sorts the input so identical IDs are on adjacent lines, then counts the number of each one, sorts by that count, descending, picks the top 3 lines, cuts off the counts (in the first 7 characters), and appends two multiplication symbols and a letter
p, which are fed todc, a reverse-Polish calculator.When
dcreceives each number, it pushes it on to its stack. The*s pop 2 numbers off the stack and push back on their product, andppops the number from the stack and prints it.At which point Part 2 is just:
That's a Bash command-line substitution saying to repeat the previous command but with (the first instance of)
-rremoved (replaced with nothing, because thes//doesn't have a replacement part). In other words, remove the-rfrom the secondsortcommand, so the counts are ascending rather than descending.It only works immediately after the part-1 command, not if you've run another command in between.
[Advent Games] Hi, I'm Smylers, from Ilkley in West Yorkshire in the UK. When not Advent-of-Code-ing I blog hints and explanations for cryptic crosswords, help run family board-game events, and attend Puzzled Pint in Leeds. One of the Christmas traditions round here is a parade featuring a few hundred tractors with fairy lights, driving through nearby towns.
My chosen ‘programming’ language is Vim keystrokes (where I eschew running a program as such, instead just manipulating the input directly in an editor window), and what I learnt about it today is, erm ... not to use it! I realized I was shelling out to run
uniq -c, at which point it seemed simpler to go a stage further and eschew even the editor window and just pipe directly at the command line. Update: I've now posted a Vim keystrokes solution (without any piping or external commands) elsewhere in this thread.Board games provide comfort and joy to me, especially when it's cold and dark outside (except when there's illuminated tractors passing, of course). Recently I've been liking Tenby, which involves creating the streets of a seaside town in Wales. On Sunday somebody taught a few of us Ark Nova, which was really good but did take 3½ hours for one game.
While not traditionally a winter sport, I'm hoping for a round of golf. I've been practising getting my (key)stroke count down. Actually, crazy golf (aka minigolf) would seem more fitting!
6
u/agorism1337 19h ago edited 15h ago
[LANGUAGE: none]
I just used unix tools and pipes.
for part A
cat input | sort | uniq -c | sort -n | tail -n 3 | awk 'BEGIN {x = 1} { x *= $2} END {print x}'
for part B, just reverse the list on the second sort. like this
cat input | sort | uniq -c | sort -nr | tail -n 3 | awk 'BEGIN {x = 1} { x *= $2} END {print x}'
edit:
I can't get code blocks to work with this code. I tried several times.
6
u/musifter 19h ago edited 5h ago
[LANGUAGE: shell]
My initial solution was to just command line it (using dc for the product):
For part 2, I changed "tail" to "head".
[LANGUAGE: Perl]
Follow up was the Perl script:
Using array slices and
productfrom List::Util.[LANGUAGE: Smalltalk]
For Smalltalk (using the GNU version), I just put the input into a Bag and used
#sortedByCount. That returns a list of associations of the formcount -> value, so I needed to deal with that:[LANGUAGE: dc]
And finally, for doing the first day in dc. I did this without
?so it will work with the new GNU version that has rebroken it. dc does not have a sort, so what I did was read things into a table (array registert) tracking the counts. The first time an element gets added, it gets pushed on register stackl(but first, a sentinel value of1is pushed... taking advantage that the input is all 3-digit numbers). Then I grab four, and compare the top with each of the three under it... leaving the lowest count value on top, which is junked after withs.. Then I load the next value and loop if > 1. So when the loop ends, it's a 1 followed by the three values I want so I just***pfor the answer (multiplying the sentinel in).For part 2, I just changed the
<rinto>r, reversing the logic that caused the stack rotation.EDIT: A slightly shorter dc version using a two stack sort (basically bubble sort, so it's a bit slower as we're sorting the full list):
6
u/voidhawk42 4h ago
[Language: Dyalog APL]
Late to the party - it snuck up on me this year!
3
u/Boojum 20h ago
[LANGUAGE: Python]
collections.CounterFTW:Not much to say, otherwise. A good simple one start us off. Certainly a bit easier than last year's
inaugural swiminaugural puzzle!3
u/jonathan_paulson 20h ago
[LANGUAGE: Python]
Code. Video. I initially did the final calculation "by hand" for both parts.
3
u/mstksg 20h ago
[LANGUAGE: Haskell]
https://github.com/mstksg/advent-of-code/wiki/Reflections-2026
Wow am I washed :) Some silly mistakes I made:
Doubleinstead ofInteven though Double never shows up in Advent of Code.All of these silly mistakes motivate me to get back in practice haha. The struggle is real.
Anyway in Haskell this is pretty simple, it reads the same in bash or any other text processing language probably. Parsing is
lines, and you can find the freq list usingData.Map.fromListWith (+). And the difference between Part 1 and Part 2 is just the order that you sort the frequencies before you sum them.3
u/JWinslow23 19h ago
[LANGUAGE: Python]
Solution writeup
Code (GitHub)
What looked at first to be a nice and easy use of
Counter.most_common...instead turned out to be a nice and easy use ofheapq.nlargestandheapq.nsmallest. I rarely get a chance to talk about those functions, so this is nice and refreshing!3
u/ednl 17h ago edited 8h ago
[LANGUAGE: C]
My goal is to write code that is as simple as possible that runs as fast as possible, with a reasonable degree of generality. My fastest version assumed that the three most common IDs had counts of 6 or 7, and least common 1 or 2. That ran in 1.17 µs on an M4 chip. But I ditched that in favour of a more general solution that works for every input depending on "maxcount" (7 for my input) but still without sorting anything. Runs in 1.50 µs on an M4, 2.36 µs on an M1, 5.33 µs on a Pi5.
https://github.com/ednl/adventofcode/blob/main/2026/01.c
3
u/flwyd 17h ago edited 19m ago
[LANGUAGE: Ivy] (on GitHub)
“Ivy an interpreter for an APL-like language. It is a plaything and a work in progress.” If you’re a regular reader of Solution Megathreads you can think of Ivy as the Alien Programming Language after you’ve put a babel fish into your ear. The entire documentation for the language is on either the linked page or in the interactive
)demo, so if you’re curious about array-based languages, Ivy may be easy to learn.You can get both parts as a 2-element array in a single line of Ivy, assuming
idsis an array of integers:Or, extracting a function to compute the frequency of each occurrence and converting
lines(an array of strings) to integers:APL-family languages have functions which can have either one (right side) or two (left and right) arguments. It’s often described as being run right-to-left, though Ivy actually runs a parse-evaluate cycle left-to-right). Functions also automatically apply to each element in an array; you don’t have to write a
forloop. So, working from the end:The
frequenciesoperator takes an array of valuesvals==is element-wise equality,@==means “for each element on the array on the left, return a boolean array of whether elements on the right are the same.” So1 2 3 @== 1 3 2 1 1 2will return(1 0 0 1 1 0) (0 0 1 0 0 1) (0 1 0 0 0 0).(unique vals)returns an array with the distinct elements fromvals, e.g.57 55 76 43 78 45for the example input. So now we’ve got an array of indices invalswhere each unique value sits.where@is a single-argument function being applied to each of those arrays.wherereturns an array of indices of an array whose value isn’t zero, e.g.(1 2 4 7 15 17) (3) (5 12 18 21) (9 11 13 19 20) (6 10 14) (8 16)for the example.count@runs thecountfunction for each of those arrays, which just returns the number of elements in it:6 1 4 5 3 2.downreturns an array of indices which would put its argument in descending order. Note that it does not sort its argument, it returns an array which can be used to sort.down 42 123 75returns2 3 1. Sodown count@ …gives us a list of indices ofvalsin frequency order.(unique vals)[down count@ …]takes that the array of indices and uses it to get elements from our list of distinct values. Yes, in array-based languages you can use an array to access an array:(42 123 75)[2 3 1] === (123 75 42).3 take …grabs the first three elements, while-3 take …grabs the last three. In the one-liner version I use3 -3 @taketo applytakeelement-wise to the two directions.*/applies the reduce modifier to the multiplication function. Together*/would be theproductfunction in some languages, orreduce(1, |accumulator, x| accumulator * x)in a functional style.[Advent Games]
Give us a quick introduction to yourself!
Tell us what country you're from
Tell us about your country's holiday festivities
Explain why you chose your programming language
Tell us what you hope to learn or have already learned about your chosen programming language
Tell us where to find your AoC repo of puzzle solutions, blag, and/or
$streaming_service!Artistic Program
Show us your holiday tree | menorah | Krampusnacht costume | r/battlestations with festive decorations!
Show us your kittens and puppies and $critters!
Show and/or tell us about whatever brings you comfort and joy in the holiday season!
Competition Schedule (Theoretical)
Tell us which "sporting" events you think will be coming up over the next two weeks and which ones you'd like to participate in the most!
3
u/CCC_037 5h ago
[LANGUAGE: Rockstar]
part 1
3
u/e_blake 3m ago
[LANGUAGE: C] [Advent Games]
This would fit in 6 80-column lines, but then it wouldn't be artistic! Compile and run with
gcc -o day01 day01.c; ./day01 < day01.inputHi, I'm Eric, living in Texas (USA)! Although I happen to share a name, I'm not as famous as the Eric (/u/topaz2078) that gives us these puzzles. But I am known around these parts for doing insane things, such as when I became last year's Red Leader with a solution in Forth compiled to Intcode running on restricted m4.
Here in the US, we love to put up Christmas Trees. So I whipped one up for my solution.
I'm planning on doing all days this year in m4 (in fact, that's how I got my stars today). But when it comes to artistic programming, I find it a bit more flexible to use a language where one- and two-character tokens are much easier to manipulate into shaped input, so I broke out the C compiler for today's post for my second pass at solving today.
https://repo.or.cz/aoc_eblake.git/tree/HEAD:/2026
2
u/seligman99 20h ago
[LANGUAGE: Python]
github
Nice to have Advent of Code again!
2
u/WilkoTom 20h ago
[LANGUAGE: Rust]
Solution. Nice to start getting warmed up!
2
u/damnian 20h ago edited 15h ago
[Language: C#]
2
u/manu_2468 19h ago edited 19h ago
[LANGUAGE: PYTHON]
I didn’t know about Counter in Python, so I used dicts. That was also a good test of my helper library that fetches the instructions and input, submits the result, and loads the input!
Code
2
u/encse 19h ago
[LANGUAGE: C#]
https://aoc.csokavar.hu/2026/1/
nothing unexpected
2
u/AllanTaylor314 17h ago edited 16h ago
[LANGUAGE: Python]
00:02:02/00:03:00code
All I want for Christmas is a
Counter.least_common(k)[LANGUAGE: Uiua]
code and a slightly rejigged pad (drop 01.txt on it to run against your input instead of the example)
I forgot that
unkeepwas a thing, which sure beats⊕⊃⧻⊢⊸⊛for counting occurences[Advent Games] A brief intro
Professionally, I'm a cloud software engineer (though most of my work work is AI-assisted. It's the way sw dev is going). I love these challenges as an opportunity to escape Cursor and have a bit of fun. I also recently started making a Minecraft mod (Marked Goats), as one does. Back in 2024, I made it to the ICPC South Pacific Finals. Outside of code, I collect and build LEGO (space permitting) and build farms in Minecraft (which doesn't take up space I don't have).
As a kiwi, I have a nice warm southern hemisphere summer Christmas (and by the luck of timezones, an 18:00 unlock time right as I finish work). Weather dependent, Christmas can be a BBQ outdoors. No tree up yet, but I swapped out the tablecloth for one that's a little more festive
I chose Python because it is easy (and I learnt/taught it at Uni), and Uiua because it is hard (I probably saw it in a megathread a few years back and was intrigued). Uiua is still evolving (not as much as last year), so I need to relearn parts of it (and maybe finally make that archive so old pads can still run - my old embed is still broken)
All the code is, as always, in the repo
Oh, and I'm wearing a Christmas shirt or tie and hat to work each day in December
.<|:-)Sports ideas:
2
u/p88h 14h ago
[LANGUAGE: Nim]
https://github.com/p88h/aoc2026/blob/main/src/day01.nim
no sorting, just counting, then counting the counts.
2
u/xelf 6h ago edited 5h ago
[Language: python]
Actually forgot it was December today and started late.
np.loadttxt for loading a bunch of ints, and then just using counter and prod.
Counter here way more elegant than np.unique/np.argsort imo.
I guess the "clever" bit here is using dict to get the keys out of the list that most_common gives you.
edit: same thing, but using pandas
19
u/Andreasnl 17h ago
[Language: Uiua]
17
u/Downtown-Economics26 20h ago
[LANGUAGE: Excel]
Part 1:
Part 2:
15
u/SU_Locker 20h ago edited 20h ago
[LANGUAGE: unix/linux command line]
14
u/Maki-Tak 19h ago
[LANGUAGE: Scratch]
solution
I fear that I won't be able to continue with this challenge for long
13
u/hakko504 17h ago
[LANGUAGE: Libre Office Calc (will work in Excel as well)]
It took me longer to write this than to do the puzzle ;)
11
u/Smylers 12h ago edited 7h ago
[LANGUAGE: Vim keystrokes] Load your input into Vim, make sure the cursor is on the first row, then type in the following and the answers to both parts will appear in your editor window:
The key to counting the number of each ID is to sort them so that all the repeated IDs are on adjacent lines, then on the first instance of each press
#to jump to the bottom one, followed byV''Jto make a visual block, jump back to where we were, and join them together (with a space in between). The number of spaces on each line then gives the count for each item.However
#will fail if there's only one of a particular ID, because there isn't another location to jump to. Avoid that by usingyGPat the start to duplicate the entire input — then there's at least 2 of each item, problem solved!Then put
0*at the start of each line, find all the spaces, and for each one press⟨Ctrl+A⟩at the start of the line to increase the count. When we run out of spaces, all the items have been counted. (The numbers shown will be double the actual count minus 1, but that doesn't matter for their relative ordering.)At which point it's just a case of sorting, (using
!so that the part 1 answer ends up before the part 2 answer), removing the counts and all the lines but the bottom 3 and top 3, then performing the multiplications — using the*s that were added as delimiters earlier. Do give it a go, and let me know if it works for you. It doesn't work on the sample input, because there aren't enough lines in the middle to need deleting.PS: For anybody curious to read my Advent of Games introduction, it's on a Bash solution elsewhere in this thread.
10
u/AMathMonkey 19h ago
[LANGUAGE: Factor]
Look at this, it's so concise and esoteric. As a career programmer, it's nice to write unreadable code for once. But for real, Factor is so powerful, and I never see anyone talk about it. Its standard library is impossibly huge, and I've had endless fun digging into it. And there are infinite ways to do the same thing, including using lexical or global variables if the stack-only approach is too intimidating. (I'm sure I'll be resorting to that in later days, but I'll resist it for as long as I can.) Shoutout to Exercism for giving me over 150 Factor problems to work on as practice for AoC.
9
u/onrustigescheikundig 20h ago edited 20h ago
[LANGUAGE: Scheme (R6RS)]
... with a rather large custom standard library that I've been using to play around with things like dynamic dispatch and learn about Clojure's internals.
Day 01 gitlab
Anyway, we're off! Fast solve today, with a terse solution.
9
u/oantolin 20h ago edited 18h ago
[LANGUAGE: Goal]
8
u/apersonhithere 20h ago edited 20h ago
[LANGUAGE: Python 3]
what's an
import? never heard of one!parts 1 & 2
8
u/reesmichael1 20h ago
[LANGUAGE: OCaml]
paste
Perhaps a slightly deranged approach, but at least it's my approach!
8
u/WesternNicator 20h ago edited 19h ago
[LANGUAGE: Anathame] my personal language
7
u/DuoSRX 9h ago
[LANGUAGE: Uiua]
6
u/YenyaKas 20h ago
[LANGUAGE: Perl]
Pretty straightforward today, as expected from Day 1.
For part 2, add
reversebeforesortor swap$aand$bin the sort compare block.6
u/Sharparam 20h ago
[LANGUAGE: Ruby]
One of those where Ruby has a nice built-in to do most of the work!
6
u/Lispwizard 19h ago
[LANGUAGE: Lisp]
Mostly Common Lisp loop macro plus some elisp, done in Termux emacs on Android tablet.
5
u/maneatingape 20h ago edited 20h ago
[LANGUAGE: Rust]
Solution. 8 µs.
Builds a
HashMapof frequencies, then converts to a sortedvec.5
u/heijp06 19h ago edited 19h ago
[LANGUAGE: C#]
I could have sworn LINQ has
Product(), apparently it does not so I had to resort to the somewhat clunkyAggregate().5
u/azzal07 19h ago edited 19h ago
[LANGUAGE: awk]
Greetings to all! (
s/for/from/)5
u/thblt 18h ago edited 17h ago
[LANGUAGE: Shell]
The lazy solution: in a shell, sort input | uniq -c | sort
5
u/ssnoyes 10h ago
[LANGUAGE: MySQL]
There's no aggregate PRODUCT function in MySQL, so there's a joke that helps me remember how to do it: https://dom.as/2008/07/03/mysql-support-fun-multiplication/
5
u/snailcuber 10h ago •
[LANGUAGE: Ruby]
code golfed down to 59 characters
5
u/PandaParado 9h ago
[LANGUAGE: Uiua]
5
u/daic0r 8h ago
[LANGUAGE: Elixir]
Solution
Count frequencies and sort, then just grab the results off of both ends of the sorted list
5
u/tqzd 8h ago
[LANGUAGE: Excel]
Part 1 & 2
5
u/dantose 7h ago
[LANGUAGE: bash]
cat input.txt | sort |uniq -c | sort -nr | awk 'BEGIN {p = 1} NR<4{p *= $2} END {print p}'
cat input.txt | sort |uniq -c | sort -n | awk 'BEGIN {p = 1} NR<4{p *= $2} END {print p}'
5
u/r_so9 6h ago
[LANGUAGE: F#] Short and sweet
5
u/itsPeetah 4h ago
[Language: Bash]
4
u/captainAwesomePants 20h ago edited 20h ago
[LANGUAGE: Python]
So glad to be back!
You know what I love about there not being a leaderboard? I still get to do the problem right at the start, but I also feel free to take my time and actually read the story, which is pretty nice. I sipped some tea. I looked up the name of that pesky Counter function that gets you the results. I chuckled about some elf's grandpa. 5/5 would take my time again.
4
u/TheShirou97 20h ago edited 20h ago
[Language: Kotlin]
Very nice when you can just remove one line from part 1 to make part 2.
4
u/FruitdealerF 20h ago
[LANGUAGE: Andy C++]
I made this programming language especially for Advent of Code. Like other it has the
frequenciesfunction to create a hashmap of the values in a list to their frequency/count. Interesting to know about this code is that there is really no difference betweenprint(product(map(input[0..3], first)))andinput[0..3].map(first).product.print)I just arbitrarily write whatever comes the most natural to me.a.b(c)is exactly equivalent toa(b,c)anda().b.cis exactly equivalent toc(b(a())). This is a great choice for a simple language to solve puzzles and questionable in most others.4
u/Gabe-tron 19h ago edited 19h ago
[LANGUAGE: Clojure]
4
u/Tipa16384 19h ago
[LANGUAGE: Forth]
I spent hours tonight familiarizing myself with Forth after years away and immediately started in on this puzzle with no break so I am a little tired and my eyes hurt but it works and I can even tell stories of how I fugged up the order of stuff on the stack a million times. More fun than FORTRAN? MAYBE!?
4
u/Alextopher 19h ago
[LANGUAGE: Rust]
https://github.com/Alextopher/advent-of-code/blob/main/y26/d01-dusty-shed/src/main.rs
Unbelievably you can solve this problem in linear time (thank you quick-select)
4
u/paulhaahr 19h ago edited 19h ago
[LANGUAGE: Quest]
Quest is a language Luca Cardelli designed in 1989 and I vibe coded an implementation of this year. I wrote about it in this r/VibeCodedLanguages post. Almost nobody's ever written code in Quest, so I thought it would be fun to try my first Advent of Code in it.
My Advent of Code repository: https://github.com/haahr/adventofcode
Quest repository: https://github.com/haahr/quest
4
u/ajf8729 19h ago
[LANGUAGE: PowerShell]
4
u/DelightfulCodeWeasel 17h ago edited 15h ago
[LANGUAGE: C++]
Part 1 & 2
Accumulate {count, id} in an array indexed by id, pick Kth largest/smallest with a heap.
~8Kb and ~190us for each part.
EDIT: ~80ms for each part on the Raspberry Pi Pico (RP2040)
4
u/lboshuizen 15h ago
[Language: F#]
github.com/lboshuizen/aoc26
Count, sort, take three. Only the sort direction differs between the parts.
4
u/fnordargle 15h ago
[Language: perl]
4
u/Interesting_Gap_6960 14h ago
[LANGUAGE: SQL]
I'm using duckdb as my database.
For part 2 I just changed the ordering to ASC
4
u/ArmadilloSuch411 14h ago
[LANGUAGE: Python]
4
u/jpjacobs_ 14h ago edited 12h ago
[LANGUAGE: Amber]
This amber language.
Try it online
4
u/pkusensei 12h ago
[LANGUAGE: Rust]
Pretty straightforward.
4
u/Witty_Arugula_5601 10h ago
[LANGUAGE: Roc]
https://gist.github.com/KevinNotDuringWork/462ac11bbda415d0d7fa502f3f44443e
4
u/Zymophilus 10h ago edited 10h ago
[LANGUAGE: R]
4
u/SleepingInsomniac 10h ago
[LANGUAGE: Ruby]
4
u/amarsuperstar 9h ago
[LANGUAGE: Elixir]
4
u/proteanbitch 6h ago edited 6h ago
[LANGUAGE: K]
4
u/Aggravating_You3212 6h ago
[LANGUAGE: Elixir]
4
u/terje_wiig_mathisen 3h ago
[LANGUAGE: Rust]
This is "Upping the ante", or maybe cheating a bit, since I'm taking advantage of the format of the input file: All the lines are 3-digit numbers + '\n', so I can load & parse four of them at the same time.
This results in 1632 ns runtime for both parts, if I can make a little bit faster then it could be rounded down to 1 microsecond. :-)
I might try to add portable SIMD here as well...
1
u/bigbolev 19h ago
[LANGUAGE: Python]
Originally solved using list comprehension, until I remembered this one.
1
u/HaskellLisp_green 18h ago
[LANGUAGE: Python]
As short as I could implement it: from collections import Counter from operator import mul from functools import reduce
1
u/Downtown_Tone1879 15h ago edited 3h ago
[LANGUAGE: C]
- day_1
- inputting into the growing array with a sorted quick sort and measuing top 3 match greatest with max count for part one and exactly opposite for part two.
[also tried the basic linux command for part one to get solution as well tho: sort input.txt | uniq -c | sort -nr | head -3] and multiplied the top results with echo $((top_result3 * top_result2 * top_result 1))
1
u/Ill_Programmer3063 15h ago
[LANGUAGE: Python & Rust]
https://brianobot.tech/blog/advent-of-code-2026-day-one/
1
u/Wayoshi 13h ago edited 4h ago
[LANGUAGE: Python3]
Fun to see all the standard library equivalents of Python's
most_commonin the other solutions here. (And of course those doing lower level languages, doing it "manually"!)1
u/CEOnism 4h ago edited 1h ago
3
u/Kehvarl 20h ago
[LANGUAGE: Python 3]
Under 10 minutes for both parts, which I'll take as a win given my rustiness this year. A nice puzzle to get me thinking in code again!
Part 2
3
u/POGtastic 20h ago
[LANGUAGE: F#]
Code
As always, a lot of Day 1 is a test of your scaffolding and built-up prelude / standard library. My
frequenciesfunction, taken from Clojure, was very helpful here.I like it when I can just pipeline everything in terms of function composition, so I ended up with
3
u/chickenthechicken 20h ago
[LANGUAGE: C]
[Part 1](https://github.com/PaigePalisade/AdventOfCode2026/blob/main/Solutions/day01part1.c)
[Part 2](https://github.com/PaigePalisade/AdventOfCode2026/blob/main/Solutions/day01part2.c)
Created a table to store the frequencies of different ID's. Then looped over it three times, picking out the largest/smallest (nonzero) frequency and setting it to zero.
3
u/mazedlx 20h ago
[LANGUAGE: PHP]
3
u/UseUnlucky3830 20h ago edited 19h ago
[LANGUAGE: Julia]
This could have been a Bash one-liner, but instead it sorts dictionary keys by values. The biggest surprise was that thingamabob and thingamajig are real English words.
Good to be back here and hope everyone has a blast solving AoC puzzles this year!
GitHub
3
u/a_gizmo 20h ago edited 20h ago
[LANGUAGE: PowerShell 7.6]
I'm sure there is a faster way to pull the last three values from the list without resorting, but I'm starting to get rusty.
3
u/EnJott 20h ago
[Language: Elixir]
Trying out elixir this year
3
u/christianqchung 20h ago edited 11h ago
[LANGUAGE: C++]
Being a little silly with ranges. Did anyone else struggle to write by hand a little, or was it just me? I don't use C++ at my day job, let alone the new features.
3
u/GassaFM 20h ago
[LANGUAGE: D]
Part 2 is the same, just without the
.retro.3
u/sim642 19h ago
[LANGUAGE: Scala]
On GitHub.
Reusing my
groupCounthelper from previous year to get the frequency map.3
u/jaspingrobus 19h ago
[LANGUAGE: Clojure]
Clojure really is pure joy for AoC, really glad I chose it this year.
For part2 replace take-last with take
3
u/Mission-Patience-854 19h ago
[LANGUAGE: Clojure]
3
u/PatolomaioFalagi 19h ago
[LANGUAGE: Haskell]
The honorable lady and/or gentleman /u/mstksg used maps, I just used lists:
For part 2, remove the
reverse.3
u/terje_wiig_mathisen 19h ago edited 19h ago
[LANGUAGE: Perl + Rust]
First Perl, extremely straight-forward using a hash, ran in 3 ms.
Next Rust, collecting the counts in a large-enough array (but with a guard to extend if needed): 6.2 us
Then I pulled all the stops by commenting out the array size guard, skipped the sorting of the counts by directly collecting the top3 and bottom 3, then I ran the processing 1000 times, each time doing 1000 iterations, then took the average from the fastest of these:
Timing starts after loading the input file into a String variable, ends before printing the results.
2265 ns
Both parts
3
u/MrJakobsen 19h ago
[LANGUAGE: elisp]
Part one is essentially:
Hardest issue was to handle multiple items with the same count. Part 2 was very similar, just skipping all the count 0 indexes.
https://github.com/BoJakobsen/coding-puzzles/blob/main/AoC/AoC2026/src/puz_01.el
3
u/AndydeCleyre 19h ago
[LANGUAGE: Factor]
on GitHub
3
u/cay_horstmann 19h ago
[Language: Java]
https://github.com/cayhorstmann/adventofcode2026/blob/main/Day1.java
OMG I was shocked how lazy my coding brain has become since last year.
3
u/Daniel_Rybe 19h ago
[LANGUAGE: Odin]
https://github.com/DanRyba253/aoc26/blob/main/day1/main.odin
3
u/LightShadow 18h ago
[LANGUAGE: Python]
3
u/light_switchy 18h ago edited 1h ago
[LANGUAGE: Dyalog APL]
Here is an alternate solution which is a little more APL-like, in my opinion.
3
u/anaseto 18h ago edited 17h ago
[LANGUAGE: Goal]
3
u/0rac1e 18h ago
[LANGUAGE: J]
3
u/lurkerburzerker 18h ago
[Language: Powershell]
Part 1
Part 2
3
u/0rac1e 18h ago
[Language: Raku]
3
u/ceochronos 18h ago
[LANGUAGE: Ruby]
Suspiciously easy. max_by and min_by were new to me.
3
u/Radiadorineitor 18h ago
[LANGUAGE: Dyalog APL]
Glad to be participating again in 2026. Let's hope for another fantastic year!
3
u/sondr3_ 17h ago
[Language: Roc]
First time in quite a while where I try to solve AoC with a new language. Quite fun, obviously today was very simple, but I'll have to go back and refactor this as I learn more Roc.
3
u/sillyshrimp 17h ago edited 17h ago
[LANGUAGE: roc]
Got excited about trying a new language.
3
u/Crusaderkingo16 17h ago edited 17h ago
[LANGUAGE: Python]
This reminded me of the lab exercises I used to do in college
Part 1
Part 2
3
u/flwyd 17h ago
[LANGUAGE: R] (on GitHub)
R is a multi-paradigm language focused on statistics, data analysis, and visualization. Many operations can be performed on whole arrays with a minimum amount of ceremony. For my purposes this year, I’m using R as one of my main array programming languages because (a) function names are derived from English and (b) imperative, functional, and object-oriented features give me stable footing to write a solution in a way that my brain already understands, then refactor towards a more typical array-oriented approach.
Today’s solution is quite simple in R, and part 1 and part 2 differ only in the value of a boolean:
The
tablefunction takeskfactors of equal length and returns ak-way array of frequencies. Here,kis just one, so it’s a table with one row of counts, and a header of IDs. Sorting the table uses that single row,namesgrabs the header,[1:3]pulls out the first three elements.3
u/xoronth 17h ago
[LANGUAGE: APL]
Well it's day 1 so I guess this was a good day to try APL.
paste
One-liner version:
3
u/andrewsredditstuff 17h ago
[LANGUAGE: C#]
Nothing like a nice one-liner:
3
u/axr123 16h ago
[LANGUAGE: Bash]
Simple one-liner:
3
u/mschaap 16h ago
[LANGUAGE: raku]
I know day 1 is supposed to be easy, but this is a bit too easy. And part 2 was trivial. Hopefully it gets a bit more interesting tomorrow.
3
u/ash30342 15h ago
[LANGUAGE: Java]
Day 1
Main part:
This could have been a one-liner, but I think this is a little bit more readable.
3
u/Direct_Chemistry_179 15h ago
[Language: C#]
prog-puzzles/advent_of_code/2026/1/main.cs at main · nrv30/prog-puzzles
I used some linq features but I saw a lot more interesting functional approaches in this sub. I'm excited to learn more this year!
3
u/NotFromSkane 15h ago
[LANGUAGE: SwiProlog]
I have no idea what I'm doing, I'm just using AoC to learn nice languages. I did a terrible attempt at APL last time.
3
u/Skuld-7 15h ago edited 15h ago
[LANGUAGE: Python]
Edit: Didn't know about Counter until I saw it in the comments. My solution is O(n²) but it gets the job done.
3
u/SpyKids3DGameOver 14h ago
[LANGUAGE: Clojure]
3
u/Jdup1n 13h ago
[LANGUAGE: R]
Github Link
Straight forward today, I don't think there is a solution with fewer functions.
3
u/HuibertJan_ 12h ago
[Language: C#]
Trying to do it all in under 1 second on my computer from 2014 (i7-4790K).
The more assumptions you can do about the input, the less you care about it blowing up, the faster the code goes.
3
u/hrunt 12h ago
[LANGUAGE: Python]
Code
I used Python's built-in
collections.Countermodule. I don't use it very frequently and was surprised to find that while it provides themost_common()method, it does not provide aleast_common()method.3
u/IvanR3D 12h ago edited 6h ago
[Language: JavaScript] Part 1 and 2
All solutions: ivanr3d.com/blog/adventofcode2026.html
3
u/Future-Custard2288 11h ago
[LANGUAGE: Chatter]
Part 1
3
u/maitre_lld 11h ago
[LANGUAGE: Ocaml]
https://github.com/MeisterLLD/AoC2026/blob/main/day1.ml
3
u/vitelaSensei 10h ago
[LANGUAGE: Haskell]
First attempt, pretty much like every other.
Prelude only version, I think this year I'll try to do all 12 days without importing anything. IDK how it's gonna go when I need to reach out to a constraint solver...
3
u/dantose 10h ago
[LANGUAGE: Powershell]
Half-assed codegolf:
Part 1 (145 bytes): $b=1;(gcb|group|sort -Property Count|select -last 3).name|%{$b=$b*$_};$b
Part 2 (146 bytes): $b=1;(gcb|group|sort -Property Count|select -First 3).name|%{$b=$b*$_};$b
I feel like this isn't a really golfable approach as I don't see any reasonable ways of tightening up the sort. I might try again in Bash.
If anyone wants to explicitly golf their solutions, I've got a thread up in codegolf: https://www.reddit.com/r/codegolf/comments/1ya5t2d/advent_of_code_2026_day_1/
3
u/tcbrindle 10h ago edited 10h ago
[LANGUAGE: C++23]
Here we go again! A nice gentle introduction as you might expect.
First we build a frequency table, using the fact that all IDs are less than 1000, so we can use a vector of pairs rather than a hash map or similar. Then it's just a matter of sorting the entries in the table according to frequency, and multiplying the first/last three IDs.
Github: https://github.com/tcbrindle/advent_of_code_2026/blob/main/dec01/main.cpp
3
u/simpleauthority 10h ago
[LANGUAGE: Google Sheets]
https://docs.google.com/spreadsheets/d/1eYa2PNrWPLVaNY6RfZBd2J10deI7EJvnCgSeLsFK9rU/edit?usp=sharing
3
u/Quasido 10h ago
[LANGUAGE: Haskell]
3
u/varma_05 8h ago
[LANGUAGE: SQL]
This is my first time attempting this advent of code and my initial thought is to solve this problem using SQL and it worked but after seeing all the comments, I have no words 🙂
SELECT id, COUNT(*) AS number FROM d11 GROUP BY id HAVING COUNT(*) > 0 ORDER BY number;3
u/red_shifter 8h ago
[LANGUAGE: Python]
3
u/mvorber 8h ago
[Language: F#]
https://github.com/vorber/AOC2026/blob/main/day1.fs
3
u/_tfa 8h ago
[LANGUAGE: Ruby]
3
u/PhilosophyLeft6189 6h ago
[LANGUAGE: Python]
Solution
3
u/lebirch23 6h ago
[LANGUAGE: OCaml]
(warning: very scuffed, i havent been coding by hand for a while + its my first time touching OCaml)
3
u/WilkoTom 5h ago
[LANGUAGE: Python]
I already announced my own entry below, but this year I've brought a young apprentice along for the sleigh ride, and this is their entry.
In the spirit of introductions to The Advent Games, and because Christmas is a time for family, we'll be recording our adventures in our blog: The Logician's Apprentice. No idea how far we'll get together, mind...
3
u/dijotal 4h ago
[LANGUAGE: OCaml]
Reverse the compare in the sort for the Part 2 bottom 3.
3
u/atrocia6 4h ago
[LANGUAGE: Python]
Part 1:
Part 2 is exactly the same, just without
reverse=True.3
u/Morphon 4h ago edited 3h ago
[LANGUAGE: Odin]
Doing AoC this year in Odin. I'm coming from Smalltalk, so this was my chance to learn some manual memory and, well, just another way of doing things.
ColorPaste
My version of Topaz's paste has syntax highlighting - feel free to use if anyone else finds it useful.
I tend to write very "teaching" style code, so this one is just as literal as one might imagine.
3
u/glebusharick 4h ago
[LANGUAGE: Lua]
Solution
3
u/LtHummus 3h ago
[Language: Lean]
Last year, I did every AOC problem in a different language and that was a fun challenge. I'm hoping to do the same thing this year (no promises) and going to try to not repeat anything I did last year.
Since Lean has been in the tech news recently due to some Riemann Hypothesis related reasons, I thought it would be appropriate to try out for the first day this year. Interesting language...I might want to play with it more.
And here's the code
2
u/hugh_tc 20h ago edited 20h ago
[LANGUAGE: Python 3] (plus manual multiplication with
bc)It's nice to be back on the west coast, where these things come out at a reasonable time. Though I'm only two hours behind EST these days!
paste, eta: cleaned up
2
u/Ok-Builder-2348 20h ago
[LANGUAGE: Python3]
Part 1
Part 2
A nice one to start this month! Fun to revisit the Counter subclass as well as dictionary unpacking.
2
u/Xeekatar 20h ago
[LANGUAGE: C#]
paste
2
u/Ok-Bus4754 20h ago
[LANGUAGE: Python 3]
here we go , looking forward for ta nice year , easy day to start with, easier than day 1 last year even, uisng python counters to get frequencies then built in most_common
https://github.com/Fadi88/AoC/blob/master/2026/days/day01/solution.py
p1 : 150 us , p2: 86 us
will port later to rust
2
u/Mikey_Loboto 20h ago
[LANGUAGE: Typescript]
https://github.com/mikeyloboto/aoc2026/tree/master/01
2
u/morgoth1145 20h ago edited 20h ago
[Language: Python] code video Times 1:16 / 1:33
Not too bad at all, just a quick sort by the counts gets us the 3 most common numbers straight away. I did lose ~12-15 seconds due to getting
valandnumbackwards in thecollections.Counter->sorted list transition initially though. Thankfully the answer was obviously way too low so I didn't get timed out.Edit: Cleaned up code, depending on your definition of cleaned up. I forgot about
collections.Counter.most_common()during the solve - using that plus a ternary and slices lets me use a common solve function!2
u/abnew123 20h ago
[LANGUAGE: Java]
forgot if there was a way to have a sorted map so just repeatedly grabbed the top element and then cleared it (very jankily).
code
Was at the airport today, but going forward will be streaming all my solutions!
2
u/Old-Dinner4434 20h ago
[LANGUAGE: TypeScript]
GitLab
I use the Bun runtime engine, running on a 2021 M1 Pro MacBook Pro. Part one completed in 1.07ms, part two in 0.96ms.
2
u/lunar_mycroft 20h ago edited 20h ago
[LANGUAGE: rust]
Simple problem to start with, biggest issue was getting used to solving them again. Made faster by the fact I had a ore-implemented
Counterto usefull code. Part 1 just sorts the ids in descending order and takes the first three items, while part 2 sorts them in ascending order instead. It's not the fastest solution, but it still parses in ~28µs and takes ~39µs to find a solution.
Using the itertools crate's
k_largest_by_keyandk_smallest_by_keymethods seems to shave off about 1µs2
u/rjray 20h ago
[LANGUAGE: Clojure]
GitHub
Just going for finish-it-fast on this one. Better anticipation of part 2 could have led to parameterizing the
reversein part 1. Saving my energy for the rise in difficulty.2
u/l4zyd3v 20h ago
[LANGUAGE: Python3]
Github
My solution isn't as fancy as some of the others haha 😅
2
u/michelkraemer 20h ago
[LANGUAGE: Rust]
Solution
I've optimized my solution to use no HashMap. The whole program runs in 30µs.
2
u/Remarkable_Ad_6266 20h ago
[LANGUAGE: Python]
2
u/NullT3rminated 20h ago
[LANGUAGE: Clojure]
Learning clojure, so I'm sure this isn't the best way to do it, just trying to be fast
2
u/Sudowiec 20h ago
[Language: Python]
2
u/hextree 20h ago
[LANGUAGE: Python]
Code
Video
Python Counter container and sorting
2
u/cicadanator 20h ago
[LANGUAGE: Javascript - Node JS]
https://github.com/BigBear0812/AdventOfCode/blob/master/2026/Day01.js
2
u/lluque8 20h ago edited 19h ago
[LANGUAGE: Scala]
Code
Well what a nice surprise for part 2. Just replace takeRight with take and be done with it.
2
u/TiCoinCoin 20h ago
[LANGUAGE: Python]
Yeay! It's that time of the year, again 🎉
day 1 starts slowly. But I realized it's quite easy if you know the right tools. Might take a little longer otherwise. And with python,
Counterandreduceare my friends here.2
u/futur3_pr3s3nt 20h ago
[LANGUAGE: Python]
2
u/ebdbbb 20h ago
[LANGUAGE: PYTHON]
2
u/cgrandsjo 20h ago edited 10h ago
[LANGUAGE: Python]
2
u/bulletmark 20h ago
[LANGUAGE: Python]
2
u/Gryphon-63 19h ago
[LANGUAGE: Swift]
Wow, after a year away from Swift I sure did forget a lot.
Code
2
u/jacoman10 19h ago
[LANGUAGE: Python]
I used a counter and math.prodinitially, but had some fun trying to see how fast I could get the function to run. I'm pretty sure that this is about as fast as it could be made in Python, though I'd love to see someone's go faster. This runs in 0.15ms on my machine.
2
u/DeadlyRedCube 19h ago
[LANGUAGE: C++23-ish] (Times: 4:46, 5:06, no AI)
Parts 1 and 2
I originally used a map to implement this, but went back and shaved a little execution time off by converting to just using an array with 1000 elements, since the IDs were all 3 digits.
Should have brushed up on my utility code before starting, I got stuck remembering how to do a few things 😅
Runs in 0.76ms, single-threaded on my i7700.
2
u/DeliciousSet1098 19h ago
[LANGUAGE: rust]
Lot of my own wrappers around things but mostly straightforward. Happy to share if anyone's interested. No AI :)
2
u/PangolinNo7928 19h ago
[LANGUAGE: Javascript]
Forgot to handle line breaks at the end of the input, was very confused why my p2 answer was initially returning as 0 lolsob
2
u/egalitarian_elephant 19h ago
[LANGUAGE: Nilang]
Code: https://github.com/Nilando/aoc_2026/blob/main/day1.nl
Did day 1 with, nilang, a scripting language written by yours truly
2
u/ThunderChaser 19h ago edited 19h ago
[LANGUAGE: Rust]
Itertools makes this problem fairly trivial with
counts,k_largestandk_smallest_by_keyI also added some nifty benchmarking harnesses to my AOC template: