This thread will keep track of my progress for Advent of Code 2024. Solutions will be spoilered.
Language: Rust (this is my first time with the language so forgive any non-idiomatic code).
This thread will keep track of my progress for Advent of Code 2024. Solutions will be spoilered.
Language: Rust (this is my first time with the language so forgive any non-idiomatic code).
@hazlin@shortstacksran.ch @karna@poa.st
Sadly have my work cut out for me this month!
cc @hazlin day 25 aoc materials. this is the last one..
between this and day 21, I was very close to giving up on this year's AoC.. I had to learn some digital electronics basics to even come close to figuring out part 2 in a reasonably efficient way.
It was refreshing how easy this day was. The second part was just it checking if you had completed all the other days' two parts.
This is definitely not the most efficient way to do part 2, but it ran in under 20 seconds which I can live with.
This one was pretty fun to implement. I got some experience with defining iterators an idiomatic way, in this case for all the edges adjacent to a node in a graph.
Memoizing ftw
I finished this some days ago but never got around to poasting it.. I spent way too long trying to brute force it and running into edge cases for part 2, and nuked my old solutions with something much simpler
This was the last problem I had left to finish and while I initially thought it was niggerlicious when I first read the problem, I felt like taking that back after finishing part 1... Then I saw part 2, and realized it was in fact very niggerlicious.
The rust docs for a binary heap had an implementation of djikstra shown as an example which felt a little like cheating since I didn't have to figure out an idiomatic implementation from scratch..
part 1 was fun. part 2 took a lot planning on pen and paper... I dont think my solution was fully general either..
this felt pretty nice since I was able to reuse a bunch of code (dijkstra) and also abuse functions returning options to shorten the syntax by converting unwraps into question marks
part 2 was pretty nuts. had to pull out some statistics and the chinese remainder theorem though i am sure there were cleaner ways to get it
debugging this was painful due to the literal edge cases
I accidentally solved part 2 while trying to do part 1 without realizing it so i don't have separate functions for the two parts.
The threw some red herrings (bolded too) in the prompt for this one... sneaky bastards
For a while I was getting filtered by part 2, but then I came across a hint that that the number of vertices of a polygon equals the number of sides (for polygons, start with a triangle and then use induction, and here we are just combing squares...) which made this easier to solve. Also helpful was printing out the grid but color-coded (pic 2 shows a test case).
This was a nice reprieve from day 12...
A day late but at least I didn't brute force it this time
Weirdly worded but not too hard once you understood the question
Just in the nick of time, but extremely inelegant code. i've also removed a bunch of the debugging scaffolding i had placed in there...
so many off-by-one errors to debug in this one...
hashing for days
I brute forced it instead of being clever about it.. turning on optimizations helped though
There's probably better ways of reading a file specified as a command line arg..
tried to make main shorter since the rest was longer.. I couldn't figure out a clean way to do this with only iterators and no explicit loops (but loops are just syntactic sugar for iterators here so it kind of works)
Not using regex made this feel so much more inelegant
@hazlin Sure, the text is too large for a single poast, so I'm poasting three files: the prompt, the test input (same as your screenshot), and the actual input (which I believe is randomized for different users). the answers to test.txt and input.txt are in the prompt file itself.
@Inginsub @hazlin If you want to see true line noise, I had done one aoc in APL and at some point implemented either bfs or dfs in it... it was something to behold
@Inginsub @hazlin oh i didnt do the APL stuff this year, it was 2022 I think, so no spoilers there (unless you are saving 2022 exercises for another day too). This year I tried rust as my unfamiliar language of choice (I typically pick an unfamiliar language and do aoc for a specific year with that). Doing 25 entirely different languages sounds like it would be either very fun or very annoying by the end of it.
@Inginsub @hazlin I agree, we dont talk about smalltalk java
cc @hazlin here's the prompt, test, and input files like before
@Inginsub @hazlin Do you have code for input parsing too? I assume you aren't doing that by hand..
@Inginsub @hazlin Part of me says thats smart, but another says this nigga is cheating
GNU social JP is a social network, courtesy of GNU social JP管理人. It runs on GNU social, version 2.0.2-dev, available under the GNU Affero General Public License.
All GNU social JP content and data are available under the Creative Commons Attribution 3.0 license.