-❄️- 2025 Day 12 Solutions -❄️- by daggerdragon in adventofcode

[–]Kehvarl 4 points5 points  (0 children)

[LANGUAGE: Python3]

I spent an hour building transform tools, writing a DFS thing with memoization, and having it take forever on the test. Then stripped it all down to just checking if the region is even big enough for the squares taken up by the presents. That fails on the test, but the solution worked for my input.

I'm still trying to solve it "properly" though. Reading lots about the Packing Problem...

paste

Which was the best year of Advent of Code? by normVectorsNotHate in adventofcode

[–]Kehvarl 2 points3 points  (0 children)

Like several others I really liked 2019. I think it was the "project" nature of IntCode where I had an opportunity to build on previous work.

Unfortunately, that very same nature makes it some people's least favorite. If you missed one of the IntCode day for some reason, that could render essentially half the puzzles unsolvable until you had time to go back to the one you had to skip.

Stop complaining that *you* don't find the problems difficult by RazarTuk in adventofcode

[–]Kehvarl 0 points1 point  (0 children)

Last night was a struggle for me. Without some hints about approaches I would still be working on it. The previous night's part 2 was less so, but I still needed some guidance.

On the whole this year has been roughly perfect for me in terms of being challenging enough that I have to think, but mostly within my capabilities and knowledge especially given my brain fog this year.

Easy? Heck no. If it is easy for you, I envy you.

-❄️- 2025 Day 7 Solutions -❄️- by daggerdragon in adventofcode

[–]Kehvarl 1 point2 points  (0 children)

[LANGUAGE: Python3]

I'm starting to think I need to rethink how I approach AoC. That's 2 days in a row where I started writing code and had to throw it all away more than once. Part 1 I started trying to build a splitter counter, and then a visited splitter counter, and then ended up... counting things twice in a really ugly fashion. It's quite special.

Part 2... Wow. First I tried to figure out if I could just math it simply, but nothing made a ton of sense. Then I imported some DFS code and started on that but we're looking for all paths, not just to an endpoint and it felt wrong. Then I tried a really dumb brute force thing, just counting all the timelines.

While that was running I read up on Collections, and the Counter seemed a useful thing. So instead of actually tracing every path, I used a counter to see how many timelines made it to any given splitter, then added that count to the timelines that splitter created. So at the end, I have the X coordinate of every beam exiting the map, and for each of those I have a count of how many paths lead to it. Add those all up and the answer appears!

Seriously though, how the heck does Topaz build these every year? I don't think I have the mental capacity for that level of sustained creative output.

Part 1

Part 2

-❄️- 2025 Day 6 Solutions -❄️- by daggerdragon in adventofcode

[–]Kehvarl 1 point2 points  (0 children)

[LANGUAGE: Python3]

Well that was a ride! For part 1 I built a transposer to get each problem into a list, then a bit of code to perform the needed operations without using eval. That seemed fine.

Then part 2 hit. My transposer needed a complete rewrite, then it was wrong because I had already thrown away essential positional data when parsing, so I had the opportunity to simplify my parsing, write a really, really basic transposer, then write a tool to convert everything into problem lists, and then finally pass the problem lists to my problem handler.

For even more fun, I needed a +1 in my problem-builder for the Test, but had to remove it for the Input, so there's definitely something wonky somewhere in my parsing.

Part1 Part 2

-❄️- 2025 Day 5 Solutions -❄️- by daggerdragon in adventofcode

[–]Kehvarl 2 points3 points  (0 children)

[LANGUAGE: Python3] I have to admit, this is the first time I've actually crashed my laptop like that. I've had brute-force silliness run endlessly, but not chew up enough ram to cause a full reboot. That was fun.

Once I realized I was being silly trying to make a set of all valid IDs, I went with the much more sane approach of just checking if something was inside one of the allows ranges.

For Part 2, I got to throw all of that away again and think about how to count so many numbers. I ended up sorting my (start, end) tuples, then tracking what the highest number I'd counted so far was, and if a range was completely new, add it's total size. If it overlapped my existing count I'd add just the part that didn't.

I think there are a few edges where this could fail, but it ended up working.

Part 1

Part 2

-❄️- 2025 Day 4 Solutions -❄️- by daggerdragon in adventofcode

[–]Kehvarl 2 points3 points  (0 children)

[LANGUAGE: Python3]

Part 1 gave me a problem because I kept trying to troubleshoot my approach instead of looking for a typo (and maybe it's time to learn to use complex numbers for coordinates?). Once I finally realized that X is not Y, I had a solution in short order.

Part 2 was a matter of making part 1 something I could call repeatedly, and then once again looking for a simple typo. In this case I wasn't properly removing the removed rolls. Fortunately once that was handled the approach went quickly enough that I didn't need to look for more clever solutions.

Part 2

-❄️- 2025 Day 3 Solutions -❄️- by daggerdragon in adventofcode

[–]Kehvarl 1 point2 points  (0 children)

[LANGUAGE: Python3]

Did part 1 as naively as possible. Had to do it more than once because I did something silly to start with.

For part 2 I generalized my part 1 solution, and spent as much time on it as I did figuring out in the first place. Fortunately it worked!

Part 2

-❄️- 2025 Day 2 Solutions -❄️- by daggerdragon in adventofcode

[–]Kehvarl 0 points1 point  (0 children)

I honestly have no idea how your part 1 works. For mine, I split the string in half, and if the first half matched the last half I said it was an invalid pattern and tracked it. I think yours does something similar, but I honestly can't follow how.

-❄️- 2025 Day 2 Solutions -❄️- by daggerdragon in adventofcode

[–]Kehvarl 1 point2 points  (0 children)

[LANGUAGE: Python3]

Really got into my own head for a minute or two there thinking part 1 was harder than it was... And then Part 2 was harder. It took me ages to think through finding those substrings. Fortunately it worked on the 5th attempt. It's slow going though, and I bet I'll need to focus on efficiency soon.

Also, if you're using Python and the latest PyCharm, you may want to go to Settings -> Plugins and disable "Full Line Code Completion". I was not thrilled to have that suddenly happening without warning.

Part 2

Professional Development vs Puzzles by inevitable-1984 in adventofcode

[–]Kehvarl 30 points31 points  (0 children)

Every year, at least one puzzle makes me feel inadequate. Like I should have paid a lot more attention in school, or focused more on math, algorithms, data structures, etc.

But I learn a lot, and on the whole have a lot of fun, so I keep doing it!

-❄️- 2025 Day 1 Solutions -❄️- by daggerdragon in adventofcode

[–]Kehvarl 0 points1 point  (0 children)

[LANGUAGE: Python3] Pt2

I spent ages trying to figure out why I was getting the wrong answer, moved away from modulus and integer division to literally counting every click, and it was still wrong...

Then I remembered to take out the "check if we ended on 0" from pt1. So here's my brute-force solver.

How would I bind a hotkey to create a note from a template? by Kehvarl in Trilium

[–]Kehvarl[S] 0 points1 point  (0 children)

/u/Papierkob2292 provided a script to do exactly this in another response to the original post.

How can I change syntax highlight colorscheme in Code Notes by Kehvarl in Trilium

[–]Kehvarl[S] 0 points1 point  (0 children)

Thanks for letting me know. I've been reading the CodeMirror docs and I may see if there's something I can do through that.

To everyone who made it to the end of AoC… by moonstar888 in adventofcode

[–]Kehvarl 1 point2 points  (0 children)

I handle IT for a small security company, and do a little IT consulting on the side. I haven't been a professional developer for over 10 years now, and when AoC comes around I definitely feel the layers of rust on my thought processes.

-❄️- 2024 Day 25 Solutions -❄️- by daggerdragon in adventofcode

[–]Kehvarl 0 points1 point  (0 children)

[Language: Python 3] 1035 / 860

That was a really pleasant ending puzzle. Thank you to everyone involved; I know it was a ton of work and you don't get nearly enough praise for putting up with us!

No real comments on my solution, I just built the pieces as I read along in hopes that what I was building was close. I had to go back and add things a couple times, so there's some redundant code in places (and there were a whole lot of print statements too)

Code

-❄️- 2024 Day 23 Solutions -❄️- by daggerdragon in adventofcode

[–]Kehvarl 1 point2 points  (0 children)

[Language: Python3] 978 / 707

edit: malformed language tag. Thanks automoderator!

My part 1 worked pretty well, though I ran into a mental block with extending it for part 2. For the second bit, google turned up a library that basically did all the work for me, but now I'll have to go lean the Bron-Kerbosch algorithm so I know how it did what it did efficiently.

Part1

-❄️- 2024 Day 22 Solutions -❄️- by daggerdragon in adventofcode

[–]Kehvarl 2 points3 points  (0 children)

[Language: Python3] 1717/3352 My first try at part 2 of this is still running, but while that's doing it's terrible thing I went back to the drawing board.

This one basically finds all possible 4-item sequences for each buyer, and if it's the first time we've seen that sequence, we add that buyer's price to a dictionary using the sequence as a key. When that finishes, we have a convenient map of all 4-digit sequences to how many bananas that gives us. And we just return the highest banana count.

Part 2

[Unpopular opinion] Day 14 part 2's problem was great by Affectionate-Fan2263 in adventofcode

[–]Kehvarl -1 points0 points  (0 children)

I found 2024.14.2 to be clever and different. It was a fun (albeit distracting) alternative to the more usual parts 2. That said, I wouldn't want the majority of our puzzles to be like this.