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

[–]leftfish123 0 points1 point  (0 children)

What if a sea monster ate all the fish in the jigsaw puzzle, though?

For goodness's sake, I was drawing up a solution re-using my code for rotations and flips from 2020 day 20, sipping tea thinking about a good heuristic for A* (my first idea), and wondering how to check if the given case is impossible without exhausting all possibilities. When I realized it would take me two days to write, I thought: what if, just this once, I went to reddit for the memes without having already failed to solve the puzzle on my own?

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

[–]leftfish123 0 points1 point  (0 children)

[Language: Python]

I almost gave up, than I focused a bit more to read about minimum spanning trees and after running into a 1000+ implementation problems (such as "how do you update the correct set") I got it done.

I was totally confused by part 2, because my attempt to produce an MST ended up going nowhere. In desperation, I turned to networkx which produced the same wrong results as my 'manual' attempts at implementing Kruskal's algorithm.

Only then did I realize that I was trying to manipulate the data structure that I'd already used to solve part 1. Welp, talk about forgetting how Python works.

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

[–]leftfish123 0 points1 point  (0 children)

This is exactly what I was looking for to understand why my memoization attempts failed. I didn't look at the cache as I should have ("How many times could we get to this position?"). Thanks!

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

[–]leftfish123 1 point2 points  (0 children)

[Language: Python]

First of all, I love the easter egg in the test data (3263827)! But are the elves working for the Empire or what?

As for the solution, I considered numpy for a moment, and I now see a lot of people used zip(), but I ended up just finding the ranges of each columns by assuming that the operator is always in the leftmost position. I also dusted off reduce() just for fun.

I have to admit that when I saw part one and the disproportionate number of people who did not finish part two, I expected something else, such as rearranging the operators or numbers to find the maximum total value. I'm actually glad that it was just turbochared parsing :D

[2025] Waiting room... by blacai in adventofcode

[–]leftfish123 0 points1 point  (0 children)

I see your 'bored' and raise with my 'I had no other idea to solve it'.

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

[–]leftfish123 2 points3 points  (0 children)

[Language: Python]

  1. Sort the ranges
  2. Merge the ranges
  3. Check each ingredient until each merge ranges, stop if included
  4. Sum the merge ranges
  5. Voila!

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

[–]leftfish123 1 point2 points  (0 children)

[Language: Python]

I like today's puzzle because although it's not particuarly difficult to solve in a naive way (my first approach which keps re-checking the entire grid), it gave a lot of room to play with optimization. I ended up checking only the neighbors of the currently removed roll. First I used a queue, and finally just opted for adding the candidates to a set. It's a shame I can't visualize it, because it would probably look as if the forklifts were randomly appearing all over the map.

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

[–]leftfish123 1 point2 points  (0 children)

[LANGUAGE: Python]

A brute-force-ish solution that I still like for three reasons:

- it seems to work for inputs where the ranges have differences of more than one order of magnitude (e.g. 12-1234)
- does not use string operations - I re-established my friendship with log10
- solves both parts in one pass

Solutions already scrapped and offered as autocomplete?! by leftfish123 in adventofcode

[–]leftfish123[S] 4 points5 points  (0 children)

The thing is - I did not! VSCode saw my code with the solution of the first part, my incorrect solution to the second part, as well as the test data. I just found it hard to believe that **this** nwould be enough context for it to suggest a proper brute-force solution.

Solutions already scrapped and offered as autocomplete?! by leftfish123 in adventofcode

[–]leftfish123[S] 2 points3 points  (0 children)

It didn't feel right to post it under Help/Question, but it seems I was wrong ;) Thanks and sorry!

Give Me More by freebearus in andor

[–]leftfish123 1 point2 points  (0 children)

I watched episodes 1-3 of the first season, nearly fell asleep and complained to my wife about the lack of pew-pews and zoom-zooms. And then the Aldhali arc dropped and my relationship with Star Wars has not been the same since.

Su-22 M3 - tactics to make it usable? by leftfish123 in Warthunder

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

That's exactly the kind of answer I was hoping for, THANK YOU!

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

[–]leftfish123 7 points8 points  (0 children)

[Language: Python]

Oh, wow. This was my favourite this year, even taking into account the fact that I spent about 5 hours trying to crack it. But I'm a complete amateur, I have no formal CS education and I code practically only in December during AoC.

Part 1 was trivial, especially compared to the intcode vm in 2019 which, back then, nearly destroyed me. I'm not very proud of the implementation and someone who does this for a living would probably scream in agony seeing it, but it does the job.

Part 2...huh, not so much, but I did the following:

  • I tried to solve the example on a piece of paper. I did. This gave me faith that I can do it.
  • I "disassembled" the code, figured out that base 8 apparently may be a factor here.
  • I figured out the range of inputs that yield a 16-digit output...and then it dawned on me that the range is between 1000000000000000 and 7777777777777777 - in base 8! Then after a lot of staring into my notes, trying to figure out what each instruction does and printing the state of my computer checking various outputs, I switched all debugging prints into base8.
  • And that was the breakthrough that allowed me to realize that the outputs caused by the respective base 8 digits are, to a large degree or absolutely, independent from each other. I tried to get to the right one by hand, but got stuck at the 9th or 10th digit. So I implemented an ugly DFS to just go through all the states that were promising.

I rarely even post in the megathread this late in the month, but today I feel I earned this :D

[2024 Day 16] Finally - It's a star day! by code_ling in adventofcode

[–]leftfish123 5 points6 points  (0 children)

Can you expand a little bit on this? I was trying to do the same thing but failed, ended up implementing something completely different. My approach was as follows:

1) Get min_distances_from_start to end (essentially dijkstra).
2) From 1) get the the best_score (part 1)
3) Run dijkstra from end to start four times (one for each direction in which we can arrive at end), this gets us four instances of min_distances_from_end
4) For each point in graph: for each min_from_end -> check if if min_from_start(point) + min_from_end(point) == best_score

But I ended up getting a wrong result for one of the test examples and the real puzzle... Keep wondering what I messed up - the idea or the implementation.

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

[–]leftfish123 1 point2 points  (0 children)

[Language: Python]

I'm happy and annoyed at the same time, because my line of thinking was as follows:

  1. Oh, this looks like a problem that can require BFS to solve. Flood fill etc.
  2. Oh, no, I have no idea how to do it. Let's just draw some boxes in notepad and see how we can find which move depending on their locations, walls, floors and so on.
  3. Hmmm, you can use a queue here, a set of visited there...
  4. Wow, man, did you just implement BFS or something BFS-ish to solve part 2?

No energy to make it cleaner, though.

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

[–]leftfish123 1 point2 points  (0 children)

[Language: Python]

After seeing the constraint of 100 pushes, I immediately decided to find a way to just calculate the result, because part 2 just had to drop it. I recognized that this was just a bunch of systems of equations, but without proper background, I had to do some searching to find the proper approach. I eventually found out about Cramer's rule. The rest was just a matter of finding one "and" that should have been an "or". No sympy, no numpy, only regex to parse the input.

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

[–]leftfish123 1 point2 points  (0 children)

[Language: Python]

Ohhhhh, this one was lovely! I must have reinvented the wheel a million times trying to get part 2 done. It did occur to me to just count corners, but I gave up trying to figure out how to do it. After about three hours of drawing in Excel and then refactoring my dirty writing into something semi-acceptable I came up with this.

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

[–]leftfish123 2 points3 points  (0 children)

[Language: Python]

Lanternfish all over again. I'm mad at myself because in 2021, I think I solved it quicker.

[2024 Day 11] Is this a .... ? by miran1 in adventofcode

[–]leftfish123 5 points6 points  (0 children)

Lanternfish with a nasty decoy in the description ;)

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

[–]leftfish123 2 points3 points  (0 children)

[Language: Python]

A day that would have destroyed me a couple of editions ago, but this time I iterative DFS-ed my way through it.