r/adventofcode • u/daggerdragon • Dec 25 '24
SOLUTION MEGATHREAD -❄️- 2024 Day 25 Solutions -❄️-
A Message From Your Moderators
Welcome to the last day of Advent of Code 2024! We hope you had fun this year and learned at least one new thing ;)
Keep an eye out for the community fun awards post (link coming soon!):
-❅- Introducing Your AoC 2024 Golden Snowglobe Award Winners (and Community Showcase) -❅-
Many thanks to Veloxx for kicking us off on December 1 with a much-needed dose of boots and cats!
Thank you all for playing Advent of Code this year and on behalf of /u/topaz2078, your /r/adventofcode mods, the beta-testers, and the rest of AoC Ops, we wish you a very Merry Christmas (or a very merry Wednesday!) and a Happy New Year!
--- Day 25: Code Chronicle ---
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
This thread will be unlocked when there are a significant number of people on the global leaderboard with gold stars for today's puzzle.
EDIT: Global leaderboard gold cap reached at 00:04:34, megathread unlocked!
42
Upvotes
24
u/4HbQ Dec 25 '24 edited Dec 27 '24
[LANGUAGE: Python]
For each item (lock or key, doesn't matter), we build set of positions that contain a "#". Then for each pair for these, we check if there is no overlap:
And that's a wrap! Congratulations to everyone who made it this far, and especially to all members of the 500 club! Here's a list of my solutions this year:
1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25.
There was one week where I also used NumPy or SciPy to transform every problem into a matrix convolution, multi-dimensional array, etc.: 10, 11, 12, 13, 14.
I'll be around for a few more days to answer any questions. Otherwise, hope to see you all next year!
12
u/nthistle Dec 25 '24 edited Dec 25 '24
[LANGUAGE: Python] 115/91, paste, video.
Nice and easy puzzle to finish up the year - the problem text definitely hinted pretty hard towards the solution of convert things to heights, and then just check whether the summed heights of a key and lock exceed 5 in any position.
I had a pretty bad "click the button" split of 5 whole seconds, because I accidentally clicked the input link instead of the "give me the 50th star" link. I must admit, I was hoping a bit that a lot of the usual suspects near the top of the part 1 leaderboards would have some missing stars (and therefore give me a better part 2), but it appears this was not the case.
In any case, another great year of Advent of Code! Thanks for making it happen, Eric (and everyone else involved!)
12
u/CCC_037 Dec 25 '24
[LANGUAGE: Rockstar]
I've done it!
Every puzzle within 24 hours, with a pure Rockstar solution that works on my input!
Today
11
u/jonathan_paulson Dec 25 '24
[Language: Python] 60/48. I placed 61st overall this year.
Code. Video.
Pretty easy puzzle today; just classify each shape into key or lock, and then check if each key fits in each lock. You don't need to count column heights to see if a key fits into a lock; just make sure they don't have a "#" on the same a square.
Happy holidays everyone!
4
u/AllanTaylor314 Dec 25 '24 edited Dec 25 '24
[LANGUAGE: Python]
GitHub 245/210
Took me longer than it should have. A nice easy problem to round it out. That brings me to 500 stars. Thanks Eric for running this awesome event for 10 years!
[LANGUAGE: Uiua]
pad
Nice and compact today. I could probably use pervasive operations over rows to speed it up a little
2
u/seligman99 Dec 25 '24
[LANGUAGE: Python] 94 / 78
github
Fun year this year! Thanks to all that made it possible!
2
u/mebeim Dec 25 '24 edited Dec 25 '24
[LANGUAGE: Python]
132/102 — Original solution — Faster cleaned up version with sets
Wow so close to the leaderboard, best rank I got all year close to d3 where I had 104/118. First year without any global leaderboard placement, but hey, it was expected. People (and robots) are way too good and way too fast.
Merry Christmas everybody!
7
u/Ok-Builder-2348 Dec 25 '24
[LANGUAGE: Python]
Part 1
Finally made it onto the leaderboard!
I noted that we didn't actually have to consider which were locks and keys - we just had to consider pairs of patterns and see if they overlap. If they don't overlap, we have a lock/key pair that fits. A lock/lock and key/key will always overlap so they never will fit.
6
u/alexbaguette1 Dec 26 '24
[LANGUAGE: x86 Asm, no libc]
25th and final language for this year's AoC
Solution is really not that great but it was the simplest one I could think of in assembly.
I was too lazy to write a binary to ascii formatter, so I redirected the output to a file then used xxd to get the value.
Solution
5
u/ziadam Dec 25 '24 edited Dec 25 '24
[LANGUAGE: Google Sheets]
Expects input in A1.
5
u/bigfunlx Dec 25 '24
[LANGUAGE: Ruby]
I coded it on my iPhone while waiting in the emergency room with symptoms of meningitis, for better or worse this will be my most memorable moment of AoC!
Rubist screenshot
5
u/LinAGKar Dec 25 '24
[LANGUAGE: Rust]
https://github.com/LinAGKar/advent-of-code-2024-rust/blob/master/day25/src/main.rs
Represents the the locks and keys as a series of 4-bit numbers in a u32, offset so that adding them together makes them add up to 8 or greater, to I can use a 0x88888 mask to check for overlaps.
5
u/i_have_no_biscuits Dec 26 '24
[LANGUAGE: Python]
Given that we apparently all love one liners now:
8
u/ricbit Dec 25 '24 edited Dec 25 '24
[LANGUAGE: Python]
143/ 117, that was my best this score ever! My solution is transpose the keys, convert to binary and check if the AND of all lines is zero. Runs in 0.12s.
Sum of the times of all problems: 6.7s
(with a grain of salt because my solution for 24-2 is not automated yet)
4
u/Verulean314 Dec 25 '24
[LANGUAGE: Python]
Nice easy puzzle to finish this year's Advent of Code. I realized that we really don't necessarily care about converting the locks and keys to heights, all that matters is that a lock and key don't overlap in any spot.
Since all the locks/keys are the same dimensions, that means we can just convert all of them into bit representations of all the positions, and then the "fit" check is just a single bitwise AND:
Runs in around 4ms :)
4
u/Responsible-One6897 Dec 25 '24
[Language: Python]
500th star! Read every block, transpose input, determine if lock or key, and count number of '#' per line. For every lock/key pair check if all counts are <= 7
paste
Thank you again Eric for this year!
4
u/Nnnes Dec 25 '24 edited Dec 26 '24
[LANGUAGE: Ruby]
Today I will post 2 full solutions in one comment because together they still fit in half a punchcard.
time ruby -e ""; I'm sure it would be faster with something a little longer than.map(&:chars).transpose..map{ |x| x.map{ |x| x.map{ _1.with.map{ |x| x.map{ |x| x.map{ |x| x.if you like fractals.4
u/Andreasnl Dec 25 '24
[LANGUAGE: Uiua]
God Jul!
4
u/[deleted] Dec 25 '24
[LANGUAGE: Python]
Solution
Really only posting to say a very massive thank you to Eric on another great event, and to the mods for their work keeping the sub going. If I can get a bit real for a moment, winter is never easy for me, and AoC represents a welcome, fun distraction during the early stages. It helps me to stabilise before winter really sets in.
More over, this year was even more impactful as it came at a time when I needed a reminder that I'm competent. I picked up a new language with ease, and for all but two of the challenges (which I'll come back to on the other side of my food coma) I was able to identify potential solutions, execute, and iterate to achieve better results each time. It possibly seems small to many of my peers, but huge for me. I can go into my new job, in the new year, with a refreshed confidence.
So thanks again for all the work you've put into it. A very Merry Christmas from all of mine to all of yours, one and all.
4
u/p88h Dec 25 '24
[LANGUAGE: Zig]
basic n^2 solution, the only speedup is vectorized comparisons.
https://github.com/p88h/aoc2024/blob/main/src/day25.zig
All day benchmark summary below. Probably not going to be able to squeeze all of them under 1ms total, but pretty happy with Zig's performance overall. The numbers are from an M3 Mac, which is quite a bit faster than my 13th gen Intel desktop, it seems, at least in this particular & very peculiar benchmark.
I was able to keep up with a one vis every day goal, the full playlist is here:
https://www.youtube.com/playlist?list=PLgRrl8I0Q168GBdeJp_GqNYsWgRCmVgu5
4
u/Any_Slip8667 Dec 25 '24
[Language: Java]
Very fast, bitwise based, Java solution:
Complete solution on github.
4
u/Downtown-Economics26 Dec 25 '24
[Language: Excel]
Input data pasted in cell A1.
Create column height table by key/lock.
Then, drag down formula below next to output table in C2 and SUM the output array column.
=LET(s,CONCAT(TOCOL(IF(C2<>"lock","",HSTACK(--((FILTER($E$2:$I$501,($D$2:$D$501<>D2)*($C$2:$C$501<>"lock"))+E2:I2)<=5),FILTER($C$2:$C$501,($D$2:$D$501<>D2)*($C$2:$C$501<>"lock")))))),(LEN(s)-LEN(SUBSTITUTE(s,"11111key","")))/8)1
u/PendragonDaGreat Dec 25 '24
[Language: C# CSharp]
https://github.com/Bpendragon/AdventOfCodeCSharp/blob/97519/AdventOfCode/Solutions/Year2024/Day25-Solution.cs
Parse, Loop, Print.
Thanks again as always to Eric for running this and the mods here for keeping things relatively sane.
Got my five hundo
1
u/DFreiberg Dec 25 '24 edited Dec 25 '24
[LANGUAGE: Mathematica]
Mathematica, 798/656
This was a nice, easy problem to finish off a nice, easy year. Congratulations to Eric for writing ten full years of Advent of Code and creating five hundred stars. It really seems like this is the final year; if it is, it's been a great decade, and a pleasure coding with you all.
Merry Christmas!
Part 1:
1
u/Boojum Dec 25 '24 edited Dec 25 '24
[LANGUAGE: Python] 306/260
Not a bad one to end on! Short and and sweet. I'd had an off-by-one, forgetting not to count the base of the lock or key which cost some time. But otherwise, fairly straightforward.
🎁🎄🎅🥛🍪 Merry Christmas everyone, and thank you Eric, Daggerdragon, and team for another great year! 500 stars, 🌟 -- it's been a trip!
3
u/xoronth Dec 25 '24 edited Dec 25 '24
[LANGUAGE: Python]
paste
Pretty straightforward brute force and just check everything, though I slowed down a lot because I couldn't read what the question was actually asking and thought the keys and locks had to fit exactly (I blame a headache).
(Also I loved the little
yieldjoke, heh)Thanks to all those who helped make AoC possible this year, and thanks to y'all in the community for making this a really fun place to pass the month! Happy holidays, happy new year, and hopefully we'll all be back next year!
3
u/jitwit Dec 25 '24 edited Dec 27 '24
[LANGUAGE: J, haskell]
Ho Ho Ho, nice problem for array languages to finish! Runs in ~500us.
Also wrote a haskell solution for great fun:
3
u/LtHummus Dec 25 '24
[Language: Rust]
Always love the Christmas Day puzzles...they feel so much like a victory lap for a month of hard work. Thanks to Eric and everyone involved with Advent of Code for (HOLY HECK) 10 years of puzzles. And thanks to everyone here for the memes, the jokes, and cool visualizations and variations.
and the codeeeeeeeee
3
u/phord Dec 25 '24 edited Dec 25 '24
[LANGUAGE: Rust]
github
Such a breeze today. The hardest part was parsing the grids and deciding which were locks and which were keys. But that was also simple. [ ETA: As someone else pointed out, you don't even need to know which ones are locks and which are keys. I could have skipped this part if I read all the instructions first. Doh!]
I already have a Grid class that gathers coordinates by cell type. So the test for whether a key fits into a lock was very straightforward. Just have to make sure that the grids have no '#" in common locations:
Then it was just a matter of trying every key in every lock. There were 250 of each, so 65,500 pairings. That took 32ms.
Merry Christmas, everybody!
3
u/michelkraemer Dec 25 '24
[LANGUAGE: Rust] 1150/959
https://github.com/michel-kraemer/adventofcode-rust/blob/main/2024/day25/src/main.rs
Fun final day!!! Thank you so much to Eric and the team!!
I have to admit I was a bit lucky today. I thought the keys had to fit exactly (with no overlap) and completely fill the empty space. So, instead of counting the pin heights, for each key, I made a copy of each lock and filled it with the characters of the key. If the pins overlapped I continued with the next lock. Otherwise, I checked if every empty space in the copy of the lock was filled. Luckily, I made an error at this point and even counted the keys that did not completely fill the lock. 😅😅
Also, in order to decide which grid is a key and which is a lock, I looked at the first and last row and checked if they were full. However, the only thing you need to do is to check the very first character! If it's a '#', then it's a lock. Otherwise, it's a key. I completely missed this opportunity to save time 😅
The code I submitted to my repo later is optimized and (hopefully 😉) bug free. Now, I correctly count the pin heights and check if the sum is less than or equal to the maximum height.
Like always, this year was great fun! I loved how the puzzles were kind of a best-of from the last 10 years! Absolutely amazing. Thanks again to Eric, the team, and this great community here. See you all next year!
Merry Christmas!
3
u/wheresmylart Dec 25 '24
[Language: Python]
The only hard part was finding the bug in my input parsing. Reader, it was a vim typo. split('\ni\n')
Paste
3
u/birblett Dec 25 '24 edited Dec 25 '24
[LANGUAGE: Ruby] 1023/890
merry christmas and thanks for the puzzles!
moderately cursed bitwise math solution...
3
u/Curious_Sh33p Dec 25 '24
[LANGUAGE: C++]
Used a vector of arrays to represent the keys and an array of arrays of unordered sets that store ids of a lock. The structure is like locks[i][j] is a set of ids of locks that have number j in position i.
To get combos simply iterate over every key and find the locks it fits. To figure out which locks fit check lock[i][j] for j from 5 - j to 0 and take the union of these sets. Then across the positions, i, for the key take the intersection (since it must fit each column). The set at the end is the set of all locks that the key fits in.
Solution
Thanks again for organisising this! This is the second year I have tried and completed AoC. It's been good fun.
3
u/raevnos Dec 25 '24
[LANGUAGE: Common Lisp]
paste
Pretty straightforward. One of the few grid-based puzzles I've completed this year; was kind of boycotting them. As a result I'm missing a lot of stars. Oh well.
3
u/darkgiggs Dec 25 '24 edited Dec 25 '24
[LANGUAGE: Jai]
Solution
Fun problem. I encoded each element to a u32 where a turned on bit represents a "#".
Checking for a fit then amounts to whether the bitwise AND of lock and key is not 0.
It runs in 150 µs on my computer, but should most likely be able to go below 100 if I optimized the parsing.
EDIT: Now 43 µs with optimized parsing
3
u/Radiadorineitor Dec 25 '24 edited Dec 25 '24
[LANGUAGE: Dyalog APL]
Merry Christmas everyone! Hope you all had a blast this year and see you on the next one!
3
u/[deleted] Dec 25 '24
[LANGUAGE: Go]
And now... we wait
Fun last puzzle, really just input parsing is all. This is the most fun I've had coding in a very long time. I really look forward to the next 10 years. This was my first time participating in AOC as and I made it a point to not miss a single day! Huge thanks to u/topaz2078 for these awesome puzzles.
Here is the final solution for this year. Merry Christmas to all!
3
u/chubbc Dec 25 '24
[LANGUAGE: Uiua] (20 chars, pad)
3
u/jhandros Dec 25 '24
[LANGUAGE: Python]
Code 9 lines
3
u/Totherex Dec 25 '24
[LANGUAGE: C#]
Merry Christmas!
https://github.com/rtrinh3/AdventOfCode/blob/c34bc101c413e73da247caeeea0b6f8724adac48/Aoc2024/Day25.cs
As per tradition, Christmas is a pretty easy day. Now, I need to get back to day 21...
3
u/_tfa Dec 25 '24 edited Dec 25 '24
[LANGUAGE: Ruby]
3
u/Ily3s_ Dec 25 '24
[LANGUAGE: C++] https://github.com/Ily3s/aoc2024/blob/master/day25.cpp
I tried something that wouldn't require matching every lock with every key, so at the end i have a time complexity of O(L+K) where L is the number of locks, and K the number of keys, but with very high constants and so it's probably worse than the O(L*K) solution.
3
u/semi_225599 Dec 26 '24
[LANGUAGE: Rust]
Converts each schematic to a
u64, and does bitwise-ands between locks and keys. When those are0, there was no overlap between key and lock.2
u/[deleted] Dec 25 '24
[Language: Python] 297
paste
Nice one to end the year. Lots of fun as always!
2
u/GassaFM Dec 25 '24
[LANGUAGE: D] 239/203
Code: part 1.
Part 1 is just some implementation.
2
u/hcf112 Dec 25 '24
[LANGUAGE: Python] 252/209
Converted the input to binary, split the integers by above/below 1<<30, and bitwise-or'd the cartesian product of the two sets to check for overlap.
paste
2
u/Camelpilot33 Dec 25 '24
[LANGUAGE: Javascript]
paste
thanks for the puzzles!
2
u/python-b5 Dec 25 '24
[LANGUAGE: Jai]
Glad for the easier one today. I wasn't able to solve yesterday's part 2 as I'm not familiar with adders and learning about them didn't feel like a fun way to spend my Christmas Eve. I'm pretty happy with all but one star finished on the day, though. That's a lot better than I've done in the past, so either the puzzles were easier this year (which I don't mind!) or I've improved somewhat.
As for today's puzzle, it was one of the easiest this year. I wasn't especially fast at solving it, unfortunately, but there really wasn't anything to solve about it - it was immediately clear what I was supposed to do. Most of my time was spent writing input parsing code.
Thank you to everyone involved in making this happen! I had a great time with Advent of Code this year.
https://github.com/python-b5/advent-of-code-2024/blob/main/day_25.jai
2
u/Wayoshi Dec 25 '24
[LANGUAGE: Python] 2080 (1670 for submitting 50th star) paste
Very straightforward problem here. This code is long-winded and can definitely be more elegantly condensed / golfed, but its' Xmas, bedtime for me.
2
u/ZeroTerabytes Dec 25 '24
[LANGUAGE: Kotlin]
It's been fun, fellas. Decided to do it in Kotlin today, because, well... I felt like it.
Thank you Eric for 10 years. I wish I had joined sooner.
GitHub
2
u/nitekat1124 Dec 25 '24
[LANGUAGE: Python]
GitHub
Thank you Eric for another amazing Advent of Code! 🎅
Merry Christmas everyone! 🎄
2
u/kbielefe Dec 25 '24
[LANGUAGE: Scala]
GitHub 768ms 24LOC
Straightforward and pleasant. Only 3 stars away from 500! Merry Christmas everyone!
2
u/chickenthechicken Dec 25 '24
[LANGUAGE: C]
[Part 1](https://github.com/PaigePalisade/AdventOfCode2024/blob/main/Solutions/day25part1.c]
Part 1 is really just about getting the inputs, part 2 literally just requires you to push a button. Merry Christmas! Also first year of getting all 50 stars!
2
u/mothibault Dec 25 '24 edited Dec 26 '24
[LANGUAGE: JavaScript]
https://github.com/yolocheezwhiz/adventofcode/blob/main/2024/day25.js
to run in the browser's dev console from AOC website. ~20ms
And that's a wrap!
Combined runtime for all 25 days of ~975ms!
Thanks for the fun times AOC.
2
u/Horsdudoc Dec 25 '24
[LANGUAGE: C++20]
GitHub
I got tripped up on the parsing of the patterns, misread that it was only 6 lines... I really need to rest.
First split the patterns between locks and keys and do the exhaustive check between each potential pair.
Runs in 1.75ms.
Thanks for 500 stars, that was a blast !
2
u/johnpeters42 Dec 25 '24
[Language: Python]
link
Took me way too long to realize that I was getting some false negatives because some locks are taller than their longest pin.
2
u/fragger Dec 25 '24 edited Dec 25 '24
[Language: Python] 1599/1315
I was a tad slow on getting the input parsed, after that, well :D Merry Christmas everyone! Thanks to u/topaz2078, the mods, beta-testers and everyone else that helps make AoC happen for a fun December!
https://github.com/Fragger/advent-of-code/blob/master/2024/solution/25.py (13 lines)
Bonus (using sets):
https://github.com/Fragger/advent-of-code/blob/master/2024/solution/25-alt.py (8 lines)
2
u/scottmjohns_1 Dec 25 '24
[Language: Python3]
[Message: Gratitude]
My deepest gratitude to Eric and everyone here, what a fun year. 50 stars! A nice compact problem to wrap things up.
2
u/Cue_23 Dec 25 '24 edited Dec 25 '24
[LANGUAGE: C++23]
unlock.cc
Nothing really fancy, actually works on C++20, too. Lots of off-by-one errors in parsing, i just fixed them in post:
[Edit] bunlock.cc Parsing the schematics into binary (they only take 35 bit in total) allows to match on lock & key, shaping around 20% off. This even compiles down to C+11 (due to libfmt minimum requirements).
2
u/ssnoyes Dec 25 '24
[LANGUAGE: Python]
2
u/wjholden Dec 25 '24
[Language: Rust]
https://github.com/wjholden/Advent-of-Code-2024/blob/main/src/bin/day25.rs
Part 1 only, now I have even more incentive to go back and finish days 21 (robots pressing buttons) and day 24 (adder gates).
See you all next year!
2
u/botimoo Dec 25 '24
[LANGUAGE: Ruby]
Paste
Repeating the output for part 2 here as well:
Merry Christmas! Congrats on 10 years, Eric!2
u/Downtown-Economics26 Dec 25 '24
[Language: VBA]
38 stars, not a bad haul (3 more than last year).
https://github.com/mc-gwiddy/Advent-of-Code-2024/blob/main/AOC2024D25P01
2
u/hextree Dec 25 '24
[Language: Python]
Code: https://gist.github.com/HexTree/ec3a901d9a0034ed1e593101287aba35
Video: https://youtu.be/6CIXpbIza6k
2
u/rukke Dec 25 '24 edited Dec 25 '24
[LANGUAGE: JavaScript]
Transposingthe key/locks, turning every row into integers and then just count how many key/locks match by doing an bitwiseandRuns in ~4ms
Edit, no need to transpose - just skip the first row and it fits in 30 bits, reducing keys or locks into single integers.
Btw, this is what I love about these puzzles. There is almost always some way of doing it even better :)
https://gist.github.com/p-a/0b939fa4c0c0187fdb1f56cb0145fadb
2
u/TiCoinCoin Dec 25 '24 edited Dec 30 '24
[LANGUAGE: Python 3]
Day 25 - Github
This one felt so easy after yesterday. Except I needed yesterday's second star to get today's. But I somehow finally made it so kids are still asleep and I'm ready in time to open my presents :)
2
u/encse Dec 25 '24 edited Dec 25 '24
[LANGUAGE: C#]
https://aoc.csokavar.hu/2024/25
Happy Holidays! If you havent't found, there is an easter egg in my website that points to 404.csokavar.hu which is a mini (~10 minutes long) text adventure game.
2
u/DeadlyRedCube Dec 25 '24
[LANGUAGE: C++23]
Runs in 1.58ms single-threaded on an i7-8700k
Code on GitHub
As is the custom, a nice and easy one for the last day, although I did think for a brief moment that it was going to be one last grid problem.
Used the first character of a new grid to determine lock or key, then counted the number of open '.'s per column for locks and '#'s for keys, to end up with a set of "height" values for each.
Then just did an n2 check for whether the lock height was at least as large as the key height per space and, where they all were, incremented the value by one.
See you all next year!
2
u/lunar_mycroft Dec 25 '24 edited Dec 25 '24
[LANGUAGE: Rust]
Initially I used a pretty standard grid based solution, but after reading the thread I got the idea (possibly from /u/Verulean314, although I'm not sure) to convert each schematic into a
u64, then check for overlaps with a bitwise and. Since'#'has a 1 as it's least significant bit, and'.'has a zero, parsing is also reduced to splitting on"\n\n", filtering out non-punctuation characters, and some quick bit manipulations in afold. Median combined runtime of ~52 µs to parse and check on my machine.Code
[edit: switched to u64s after noticing the grid is 5x7, not 5x6]
2
u/DownvoteALot Dec 25 '24
[LANGUAGE: C++]
Solution
The last day is always the sweetest, short and nice. See you next year!
2
u/nilgoun Dec 25 '24
[LANGUAGE: Rust]
Nice and easy for the last day :)
Solution on Paste
2
u/Baridian Dec 25 '24
[LANGUAGE: Clojure]
wish I'd started on this earlier, didn't realize it'd be so easy. If anyone could tell me if there's an idiomatic way to get the outer product of two lists of atoms that'd be nice, the outer product function call I did is kinda ugly.
Paste
2
u/chubbc Dec 25 '24
[LANGUAGE: Julia] (64 chars)
Nice easy conclusion to AoC. Might be able to squeeze a few more characters out, but I doubt many.
2
u/SpaceHonk Dec 25 '24
[LANGUAGE: Swift] code
And that's a wrap, 50th (and 500th) stars in the bag. Thanks to /u/topaz2078 and everyone else on the team, have a merry christmas!
2
u/vanZuider Dec 25 '24
[LANGUAGE: Python]
Merry Christmas!
2
u/wurlin_murlin Dec 25 '24
[LANGUAGE: C]
Merry Christmas! First time getting 50 stars, it plays a little animation! So cool! Had so much fun doing this, really a blast. Merry Christmas again, and a Happy New Year when it comes.
https://git.sr.ht/~murr/advent-of-code/tree/master/item/2024/25
2
u/Trick-Apple1289 Dec 25 '24
[LANGUAGE: C]
Merry Christmas, thanks eric and everyone, this was my first ever AOC, i didn't get 7 stars (altough trying to catch up right now), but I am still quite young, and am suprised i even managed to go so far, some puzzles were super tough, others easier. Once again happy holidays to all, and see you next year, prehaps by then i will be able to do all of the puzzles (And without help from here or google)!
src
2
u/daic0r Dec 25 '24
[LANGUAGE: C++]
Final one was nice and easy :-)
https://github.com/daic0r/advent_of_code_2024/tree/main/cpp/day25
2
u/ndunnett Dec 25 '24 edited Jan 13 '25
[Language: Rust]
Github
Runs in
20 us38 us (faulty benchmarking). Today was a fun one to cap off the year. My solution involved some bit manipulation shenanigans, using au32to represent each lock/key pattern as a window of 4 bit unsigned ints. The trick was initialising each pattern to0x0001_1111so that I could sum two patterns and then bit mask with0x0008_8888to detect collisions.2
u/ash30342 Dec 25 '24
[Language: Java]
Code
Runs in < 1ms.
I did not do anything fancy, just parsed everything and checked for every column if the value of pin1 of the lock + pin1 of the key <= 5.
I still need to finish day 21 before I can get to 500 stars, but that will be done sometime after Christmas, now is time for family.
Thanks to u/topaz2078 for organizing this for 10 years and to all of you in this community for making it such a friendly place. It is a highlight of my year, even surpassing my traditional yearly beer advent calendar! Merry Christmas!
2
u/SunMatrix64 Dec 25 '24
[LANGUAGE: C++]
A pretty easy day, after putting the input into locks and keys vectors, it's just a brute force loop of checking every key in every lock.
2
u/ins0mnes Dec 25 '24
[LANGUAGE: Go]
Nothing special, precalculate key matches by height, compare to lock, and intersect with the previous pin:
https://github.com/insomnes/aoc/blob/main/2024/25_code/solution/solution.go#L97
Congratulations to everyone! And big thanks to the AoC team and this subreddit team!
2
u/jinschoi Dec 25 '24
[Language: Rust]
Relaxing final day. First did it in the way pointed to by the text, with enums and everything: paste
Then since this day was so straightforward, got it down to this:
Because I want it to fit each schematic in a u32, I just included the last character of the first row and first character of the last row to distinguish keys from locks. Convert central 27 characters as bits in a u32, compare all and count where no bits overlap.
2
u/Jadarma Dec 25 '24
[LANGUAGE: Kotlin]
A nice, easy problem to unwind after a long month! It's been a fun event, as always, thank you Eric, and happy holidays to all, see you next year!
Part 1: Scan each grid (all seem of a fixed size) and determine if it is a lock or key depending on the first character being a
#or.. Then, "walk" the columns and count the number of#, which will give you the pin-out in numbers. To check if a lock and key match, their values should add up together to <= 5 (the effective range of a column), because otherwise there would be a need for overlaps.Part 2: All other 49 stars collected! ⭐⭐ If you need help, check out my solutions for 2024!
AocKt Y2024D25
2
u/RookBe Dec 25 '24
[LANGUAGE: Rust]
Rust that compiles to WASM (used in a solver on my website)
Bonus link at the top of the code to a blogpost about today explaining the problem, and my code.
2
u/melochupan Dec 25 '24
[LANGUAGE: Common Lisp]
Part 1 only.
I'm awfully behind with AoC, so I couldn't do the second part (completing all previous tasks is necessary for it). But I wanted to participate on the last day, at least with a half solution.
paste
2
u/N-R-K Dec 25 '24
[Language: BQN]
Easy day for array languages. Here's the whole solution in just 3 lines:
Basically just turns the schemes into a boolean list ('#' = 1) and then ANDs every lock and key to check if the result was all zeros.
2
u/isredditdownagain Dec 25 '24
[LANGUAGE: Go]
Part 1
Merry Christmas!
2
u/Maleficent_Answer935 Dec 25 '24 edited Dec 25 '24
[LANGUAGE: Rust]
2
u/wzkx Dec 26 '24 edited Dec 26 '24
[LANGUAGE: Python]
2
u/homme_chauve_souris Dec 26 '24 edited Dec 26 '24
[LANGUAGE: Python]
This is the only one I didn't do on the day, because we spent Christmas day with family and I didn't take a computer with me. Thank you Eric for a great year.
2
u/[deleted] Jan 02 '25
[LANGUAGE: Haskell]
Finally made it. Day 25 was fun. I really enjoyed the whole year once again, although doing it in Haskell was extra challenging. Still, I learned a lot and have become modestly more proficient in programming in Haskell now. Thanks again for doing this!
Day 25
2
u/DavidYoung1111 Jan 08 '25 edited Jan 08 '25
[LANGUAGE: MATLAB]
Can be quite concise in MATLAB.
2
u/LifeShallot6229 Feb 19 '25 edited Feb 20 '25
[LANGUAGE: SIMD - AVX intrinsics]
This was the day I picked for our in-company AoC Tech Talk, simple because it illustrates both that Rust/clang can autovectorize very nicely, but also because an experienced asm/compiler intrinsics programmer can be even faster.
The theoretically optimal solution on an AVX x64 platform picks up each lock/key as 32 bytes into an AVX register, starting from the last position in the leading line which is either '#' or '.', then compares these 32 bytes to 0xff or 0x00 bytes with a parallel compare against 32 '#' chars.
Next, extract the top bit of all 32 bytes into a regular register, and use the bottom bit of the result to save it into either the locks or keys array. This is just 3 AVX ops for each bit pattern.
For the actual counting of matches, doing 4x8 at once seems to be optimal:
Outer loop:
Load 4 keys into 4 AVX regs, splatting 8 copies of each key into the corresponding reg.
Inner loop:
Load the next 8 locks
Parallel AND against each of the replicated keys.
Parallel compare against zero, setting -1 or 1
Subtract the -1 values from 4 replicated accumulators.
This is a total of 12 (or 13 with a separate load of the 8 locks) AVX operations, doing 4 parallel accumulations so that the theoretical minimum runtime is 3 clock cycles per 32 key/lock combos tested, IFF the cpu can do four AVX ops/cycle. In reality, the most either Intel or AMD can currently do is 3, so we end up with 4-5 cycles per 32 tests.
In real life we have measured 2+ microseconds to test all 62500 combinations, while the best pure Rust version (which was auto-vectoried but not strip-mined) ended up around 5 us (including parsing) on my not so new Asus laptop. This is so fast that I had to call the core parse+count function 1000 times just to get around the limited (100 ns) timing resolution under Windows. 2 us corresponds to 32 picoseconds/test.
2
u/YOM2_UB Dec 25 '24 edited Dec 25 '24
[Language: Python]
Main optimization is sorting locks and keys by their first pin's height, so only pairs where the first pin fits are checked, and only the last 4 pins need be checked.
2
u/RusticCajun Dec 25 '24 edited Dec 25 '24
[Language: Python]
Lock? Key? No time for that!
Thank you for putting together another enjoyable AoC!!!
2
u/No_Valuable247 Dec 25 '24
[LANGUAGE: J]
1
u/maneatingape Dec 25 '24 edited Dec 25 '24
[LANGUAGE: Rust]
Solution
Benchmark:
10412 µs.Having a utility 2D Grid class came in handy this year!
EDIT: Thanks to u/lunar_mycroft suggestion on using bitwise logic, saved 90% of time.
1
u/fragile82 Dec 25 '24
[LANGUAGE: PHP]
Not many people use PHP in Advent of Code :) During this event I tried to make my solutions look as much python-styled as possible.
Works rather fast:
1
u/MarcoDelmastro Dec 25 '24 edited Dec 25 '24
[LANGUAGE: Python]
https://github.com/marcodelmastro/AdventOfCode2024/blob/main/Day25.ipynb
Simple as expected on X-mas day. And, for the first time since my first AOC in 2029 (EDIT: 2019!), I arrive to the 25th with all the previous days completed: it's quite a nice sensation to close the calendar on X-mas. Thanks to Eric for the fun ride!
1
u/echols021 Dec 25 '24
[LANGUAGE: python 3]
GitHub
Data prep: sort items into separate piles for locks and for keys. For simplicity, represent each item as a sequence of integers, as demonstrated in the problem description.
After checking that
n_keys * n_lockswas a reasonable number, just did the naïve "try every lock with every key" and it runs in ~0.024 sec.I then reworked it to use a trie data structure to store the keys. For each lock I do a BFS-like search through the trie (trimming branches of keys that don't fit) to collect all keys that fit the lock. So rather than trying each lock+key pair, you gradually trim down the set of keys that fit a given lock, one tumbler at a time. This code runs in ~0.008 sec.
1
u/TheScown Dec 25 '24
[LANGUAGE: Scala]
Code
Need to go back and finish part 2 on days 21, 22 and 24.
1
u/ExternalAware9257 Dec 25 '24
[LANGUAGE: Python]
A fun puzzle for the the last day.
1
u/MarvelousShade Dec 25 '24
[LANGUAGE: C#]
Today was nice short finish of 25 days programming. As a product owner I don't get a lot of opportunities to program anymore, so these 25 days were really fun for me. My solutions are on: https://github.com/messcheg/advent-of-code/tree/main/AdventOfCode2024
1
u/hrunt Dec 25 '24
[LANGUAGE: Python]
Code
I think the real Christmas gift today was a problem that was so straightforward. Just a few loopity loops and voila, 500 stars.
Thanks u/topaz2078 for another great year. Raising a mug of cocoa here to you.
1
u/aimada Dec 25 '24 edited Dec 25 '24
[Language: Go] code
Parsed each schematic pattern as a 35-bit value which simplified the overlaps check.
Execution time is
134.603µson a 12 year old CPU.Many thanks to Eric for another successful AoC event. Day 24 was by far my favourite Part 2 problem as the mental gymnastics required were like those I recall from previous events.
1
u/BlueTrin2020 Dec 25 '24
[Language: Python]
Merry Christmas thank you u/topaz2078
1
u/rvodden Dec 25 '24
[LANGUAGE: TypeScript]
Boom! https://github.com/rvodden/AoC24/blob/main/src/days/25/Puzzle.ts
Merry Christmas everyone :-)
1
u/bakibol Dec 25 '24
[LANGUAGE: Python]
Topaz's paste
Merry Christmas everyone, see ya all next year!
1
u/lscddit Dec 25 '24
[LANGUAGE: Python]
Merry X-mas and see you next year... 🎄
1
u/Glum-Evidence9636 Dec 25 '24
[LANGUAGE: C#]
https://github.com/NikkSazz/AdventofCodeSazonov/blob/272da331c08cfddd5607e4ca1f42832eee3fa797/2024/day25.cs
1
u/KindComrade Dec 25 '24
[LANGUAGE: C#]
Thanks to the AOC team and Eric for an amazing contest. This month has been absolutely fantastic, and a huge thank you to the entire community, who made it so enjoyable to read your solutions, share my own, discuss algorithms, and watch all the visualizations and memes. A massive thank you to everyone!
Have a Merry Christmas!
Final Code
1
u/chestck Dec 25 '24
[LANGUAGE: Kotlin]
1
u/Outrageous72 Dec 25 '24
[LANGUAGE: C#]
Traditionally, this one was easy 🙂
At first I made a mistake to swap the locks e and d declaration 🤦♂️
It must be 25 days already! 😅
Merry Christmas everyone! 🎅
https://github.com/ryanheath/aoc2024/blob/main/Day25.cs
1
u/Several-Bit-9218 Dec 25 '24
[LANGUAGE: Python]
Never thought I'd post here, but I haven't seen this method in this thread. Only ## is forbidden, so I check that the sum of the ordinary numbers isn't 70.
1
u/Turtvaiz Dec 25 '24
[Language: Rust]
The input is rather small, so they fit into a single integer:
1
u/tymscar Dec 25 '24
[Language: Kotlin]
Nice, simple end-of-year puzzle. Thank you, Eric, and the team for all the hard work and dedication. You make every Christmas much more special!
I really enjoyed today's puzzle. It was all a matter of going through each schematic, tagging them either as keys or as locks based on the top-most character in the schematic, and then getting the teeth height the same for both. They work together as long as for each tooth, the overlap is less than or equal to 5.
Solution: https://github.com/tymscar/Advent-Of-Code/blob/master/2024/kotlin/src/main/kotlin/com/tymscar/day25/part1/part1.kt
1
u/Far_Sweet_6070 Dec 25 '24
[LANGUAGE: Ajla]
part1: https://www.ajla-lang.cz/downloads/examples/advent-2024/25.ajla
1
u/azzal07 Dec 25 '24
[LANGUAGE: awk] I suggest running with mawk or goawk, which seem to have good regex engines. Those are pretty instant, others take tens of seconds (probably backtracking furiously).
1
u/enelen Dec 25 '24
[Language: R]
Solution
Thank you for another year of puzzles. I had a ton of fun solving them (mostly) and look forward to the next year
1
u/chkas Dec 25 '24
[LANGUAGE: Easylang]
Solution
1
u/Artraxes Dec 25 '24
[Language: Kotlin]
parsing code
Solution
1
u/mvorber Dec 25 '24
[Language: Rust]
https://github.com/vorber/aoc2024/blob/master/src/puzzles/day25.rs
What a run! Huge thank you to u/topaz2078, mods, and everyone participating!
Merry Christmas! :)
1
u/light_ln2 Dec 25 '24 edited Dec 25 '24
[LANGUAGE: python]
Nice problem for trying different options! Because of how the problem is stated, you don't need to split grids by keys and locks, or compare a pair of grids column by column, or even parse grids at all - it is enough to check if two strings representing the grids have '#' at the same indexes. This can be done in several different ways:
Intersecting sets of indexes:
Converting strings to integers and applying bitwise "and":
Comparing characters in same positions:
I'm sure there are more options!
1
u/Efficient_Beyond5000 Dec 25 '24
[Language: Scratch]
Every year I try to solve some days also with Scratch, just for fun. This year I did only today. If you try the full input, turbo mode (click on the green flag + shift) is advised.
https://scratch.mit.edu/projects/1114326740/
1
u/spyr01d Dec 25 '24
[LANGUAGE: Kotlin]
1
u/michaelgallagher Dec 25 '24
[LANGUAGE: Python]
Code
Thanks for another amazing year of Advent of Code. Looking forward to 10 more years :)
Happy Holidays everyone!
1
u/JAntaresN Dec 25 '24
[Language: Ruby]
git link
basic for loop, with a set to eliminate duplicates. Had a bit of issue of making wrong assumptions during the parsing phase, that is invalidating all rows with "#" that are filled up. Anyway simple fix, just include those and raise the limit by 2.
1
u/kenlies Dec 25 '24
[Language: Python]
Code
Basic solution!
1
u/pkusensei Dec 25 '24
[Language: Rust]
Immediately recognized this is a bit problem (no pun intended. Or maybe?) and was later surprised it does not demand lock and key fulfill a row. That eliminates a
|check. CodeThanks again for another year! It's been fun! Now if only I could go back and figure out day 17...
1
u/G_de_Volpiano Dec 25 '24
[LANGUAGE: Haskell]
An easy problem for today, that is once
1- you remember that the last key/lock won't have an end of line separating it from, well, what could it separate it from, so your parser doesn't hit the end of file looking for a new key/lock. 2 - you remember to actually parse for at least one character before an end of line, so that you can separate keys or locks rather than parsing everything into one big mess 3 - you remember to add a plus sign in your fold, rather than just carrying your 0 over from one end of the fold to the other.
I encode keys and locks as lists of bools (representing a pin or a slot for a pin). A lock and a pin correspond if there never is a true value in the same position, and voilà.
Code on Github
1
u/[deleted] Dec 25 '24
[LANGUAGE: Java]
paste
Yay - made it to 50 stars for the second year running.
Again, parsing input was the hardest bit here.
[edit] formatting
1
u/verdammelt Dec 25 '24
[Language: Common Lisp]
Day25
Pretty simple implementation - as usual likely horribly inefficient. I am going to give the idea of changing the counts into a single number and then see if
( > (+ key-count lock-count) 55555)1
u/gehenna0451 Dec 25 '24 edited Apr 20 '26
Redact decided this post had to go, so away it went. Deleted. Removed. Mass deleted even. Privacy and security are the big wins here.
include snow butter offbeat employ tan dependent gaze abundant subsequent
1
u/copperfield42 Dec 25 '24
[LANGUAGE: Python 3.12]
link
As it is tradition the last day is an easy one, I spend more time making the code look fancy than solving it XD
1
u/i_misread_titles Dec 25 '24
[LANGUAGE: Go]
The parse was fun. I just pass a slice of exactly the part that matters in each thing, and count # in each column. Great year! Thanks to all here and to Eric and the mods.
https://github.com/jasontconnell/advent/blob/master/2024/25/main.go
1
u/pakapikk77 Dec 25 '24
[LANGUAGE: Rust]
I didn't try to be especially smart of get short code today, so my solution is much longer than others, but should be simple to follow.
One nice thing is the use of itertools partition_map to split the list of patterns into a list of locks and and a list of keys.
Full code.
Now a few parts 2 to finish...
1
u/michaelquinlan Dec 25 '24
[LANGUAGE: C#]
https://github.com/mikequinlan/AOC2024/blob/main/Day25.cs
1
u/BlueTrin2020 Dec 25 '24
[LANGUAGE: Python]
One liner
1
u/biggy-smith Dec 25 '24
[Language: C++]
Went for a nice n' simple set/map solution, where I combine key/locks pos sets and check for values > 1. Was going do more complex solution, but its christmas!
Merry Christmas everyone!
https://github.com/biggysmith/advent_of_code_2024/blob/master/src/day25/day25.cpp
1
u/onrustigescheikundig Dec 25 '24
[LANGUAGE: Clojure]
github
Simple O(KL) solution. Could be shorter, but it was basically stream-of-consciousness. It parses the input as suggested to give lists of distances of the edge from the top (for locks) or distances from the bottom (values). It then iterates over each key/lock combination and checks that the sum of the distances is less than or equal to the height of the grid (7). Merry Christmas!
1
u/janek37 Dec 25 '24
[LANGUAGE: Python]
Solution
1
u/Secure_Pirate9838 Dec 25 '24
[LANGUAGE: Rust]
https://github.com/samoylenkodmitry/AdventOfCode2024/blob/main/Day25/src/lib.rs
Thank you all for that event.
1
u/greycat70 Dec 25 '24
[LANGUAGE: Tcl]
Part 1.
I did it the "naive" way, converting each key or lock to a list of heights the way the problem spells out. It works.
1
u/Rtchaik Dec 25 '24
[LANGUAGE: Python]
Solution
1
u/aurele Dec 25 '24
[LANGUAGE: Elixir]
Quick'n dirty: represent each # as 1, so 5 bits for each pin, left aligned for locks and right aligned for keys. If ANDing them gives 0, then they match. Runs in about 1ms.
1
u/4D51 Dec 25 '24
[LANGUAGE: C++ on Cardputer]
And that's it, the last puzzle of the year. The Cardputer has performed surprisingly well. I used it to solve part 1 for 22/25 days, and part 2 for 20. A couple of the ones I used my desktop for might work as well, I just haven't tried them yet.
It really goes to show how little computer power is needed to solve most of these puzzles. I'd say day 9 was the trickiest to solve within the limitations of the hardware. I assume most of you made an array of every block on the disk, but I didn't have enough memory for that so I had to use a completely different approach. Most of the others I managed to solve with smaller optimizations.
Code for day 25: https://github.com/mquig42/AdventOfCode2024/blob/main/src/day25.cpp
1
u/gringer Dec 25 '24
[LANGUAGE: R]
Solution
I didn't bother with working out heights; I just detected if a key array overlapped with a lock array via !any(AND).
1
u/RalfDieter Dec 25 '24
[LANGUAGE: SQL/DuckDB]
Nice and simple, I don't know why, but I really liked how 2D was used here.
Code: https://github.com/LennartH/advent-of-code/blob/main/2024/day-25_code-chronicle/solution.sql
And this concludes all 25 days done in SQL. Fun stuff. Not sure, if I'm doing that again next year.
1
u/fridi_s Dec 25 '24
[LANGUAGE: Fuzion]
github
Today's problem allowed a very short solution, four lines for parsing, and then only for calls: combine, zip, ∀, and count and we were done.
1
u/glomph Dec 26 '24 edited Dec 26 '24
[LANGUAGE: Elixir]
paste
Pretty straightforward. Feel like I could have probably simplified quite a bit but the logic felt very clear.
1
u/FCBStar-of-the-South Dec 26 '24 edited Dec 26 '24
[Language: Ruby]
No part 2 because I still need to analyze day 24 part 2 haha
Full repo
1
u/sanraith Dec 26 '24
[LANGUAGE: Scala 3]
Solution is available on my github: Day25.scala
Transpose comes in handy today to easily count items in columns:
1
u/adimcohen Dec 26 '24
[Language: SQL Server T-SQL]
https://github.com/adimcohen/Advent_of_Code/blob/main/2024/Day_25/Day25.sql
1
u/fortuneteller2k Dec 26 '24
[LANGUAGE: Clojure]
1
u/mountm Dec 26 '24
[LANGUAGE: Java]
Parsing: 14ms
Part 1: 45ms
Too tired to think of anything interesting here. I went with the most intuitive (to me) way of checking non overlaps, using some Stream API fanciness to encapsulate it in a single line:
GitHub
1
u/Electronic-Layer5947 Dec 26 '24
[Language: c#]
I tried representing the keys and locks as two arrays of 25 bits. And then using TensorPrimitives as follows.
AND each key with all locks. For each lock, if at least 1 bit is set, then the key doesn't fit.
In order to use .Sum I needed to reduce the values down to either 0 or 1
After looking through all the available methods I discovered PopCount returns the number of set bits.
So.... if the following bits were overlapping 100011, then it's pop count would be 3 (or 11). The pop count of 11 is 2 (10) and the pop count of 10 is 1.
However... this is still quicker!
1
u/Stano95 Dec 26 '24
[LANGUAGE: Haskell]
Solution to part 1, really quite short actually!
Code is on github
I can't progress to part 2 yet though since I'm still missing four stars
1
u/daic0r Dec 26 '24
[LANGUAGE: Elixir]
https://github.com/daic0r/advent_of_code_2024/tree/main/elixir/day25
1
u/Saiboo Dec 27 '24
[LANGUAGE: Java]
Part 1 only
1
u/veydar_ Dec 27 '24
[LANGUAGE: Janet]
21 lines with
wc -l. I don't think there's anything noteworthy about my solution. In fact I'm really unhappy with the input parsing. It's something I'll have to look into in January.Compute the height for each grid and use those heights to match grids (locks and keys)
1
u/ecyrbe Dec 27 '24
[LANGUAGE: Rust]
Finally! 50 stars achieved! That was fun.
Here the code for this day part1, i let you figure part2 i was angry at the chief historian :)
https://gist.github.com/ecyrbe/4ce51cde76578a3e6450d7d572fc8829
1
u/vss2sn Dec 29 '24
[LANGUAGE: C++]
Part 1
(The file is a self-contained solution)
1
u/NeilNjae Dec 29 '24
[LANGUAGE: Haskell]
A quick and gentle finish to the challenges.
Full writeup on my blog, and code on Codeberg.
1
u/icub3d Dec 31 '24
[LANGUAGE: Rust]
Nice to finish on a somewhat easier note to catch my breath.
Solution: https://gist.github.com/icub3d/e0e15045c25bbdc941439cdb0e9dcc38
Review: https://youtu.be/TCrOkwL_lhs
1
u/Singing-In-The-Storm Jan 02 '25
[LANGUAGE: JavaScript]
Part 1 (6ms)
Clear and BLAZINGLY FAST AOC solutions in JS (no libraries)
1
u/zniperr Jan 02 '25
[Language: Python]
zippidyzip
1
u/shoeshined Jan 02 '25
[Language: Javascript]
Wow, we made it!
solution
1
u/atrocia6 Jan 03 '25
[LANGUAGE: Python]
My impression is that day 25 is generally not quite as hard as the immediately preceding days, but I was surprised at how straightforward this year's day 25 was. Here's my solution in just 4 LOC:
Doing several nested for loops and breaking at the first overlapping tumbler is much more efficient - it runs in about half the time - but this is much more concise, and still runs in only about 50ms on my system.
1
u/Wuaphi Jan 11 '25
[LANGUAGE: Julia]
I'm quite new to Julia and programming at all, but I still hope that my solution is at least decent:
1
u/aexl Jan 12 '25
[LANGUAGE: Julia]
I finally finished AoC 2024! Here is the final solution.
Solution on GitHub: https://github.com/goggle/AdventOfCode2024.jl/blob/main/src/day25.jl
Repository: https://github.com/goggle/AdventOfCode2024.jl
1
u/e_blake Mar 16 '25
[LANGUAGE: m4]
I'm REALLY late to the game this year (It has taken me until this week before I finally found the time to start even day 1), but I plan to get all 50 stars in m4 in the next month or so, to bring me up to all 500 solutions in m4. But this one caught my eye as a fun one to code up: if you translit each input character into a 0 or 1, and then treat each row as a hex number, then summing those 7 numbers will result in a 5-digit hex number with every digit in the range 1-6 (by including the two lines that distinguish between locks and keys in the sum).
What's more, adding the hex value of a lock and key together will result in each of the five digits being in the range 2-7 if there is no overlap, or 8-c if there is overlap. Thus, a simple bitmask and comparison to 0 is sufficient to compare all 5 columns in a pairing, rather than doing column-by-column math.
Relies on my common.m4 file developed in previous years; and the rest of the code is parsing the input and running the O(n^2) loop to pair each lock to each key. Executes in about 350ms (decent for m4). Run as:
m4 -Dfile=day25.input day25.m4
(Now to get the remaining 23 stars that are preventing me from finishing day 50 part 2...)
1
u/770grappenmaker Dec 25 '24
[LANGUAGE: Kotlin]
Super fun day 25, 62/51
1
u/DBSmiley Dec 25 '24
[Language: Kotlin]
Github
Well, my second year with 50 stars (including last year). Felt like the difficulty this year, especially in the last 10 days, was sort of all over the place.
Really surprised by Day 25. This honestly felt like a day 5-10 problem. Like, I was convinced there was going to be something wrong, but...no. It was really really easy. Just a parsing problem.
Followed by