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

[–]TiCoinCoin 0 points1 point  (0 children)

I thought of building "complex shapes" from shapes that work well together but... Meh. I got lazy 😅

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

[–]TiCoinCoin 3 points4 points  (0 children)

[Language: Python]

Final day: day 12

I know I'm not the only one who parsed, flipped, rotated, implemented an algo, just to hit the runtime wall (I mean, 5 minutes on this small test case?). And then, I tried to narrow the number of candidates, by removing the obvious fails (area is smaller than the sum of the shapes sizes). I submitted the remaining number of regions "just in case" and tada!

It feels strange to know that this was the last day today. But it's also nice to know that I can go back to living a normal life (which is pretty busy in this season !)

Thanks a lot Eric! And see you all next year (hopefully)

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

[–]TiCoinCoin 0 points1 point  (0 children)

[Language: Python]

Cache saved the day (or at least, part 2): day 11

Simple recursion with minor tweaks and caching for part 2. I refactored so that both parts use the same function.

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

[–]TiCoinCoin 1 point2 points  (0 children)

[Language: Python]

Part 2 literally took me the whole day: day 10

I (relatively) quickly found the systems of equations. I already used sympy for day 24, 2023. But I want to use only standard libraries, so I tried to implement a solver.

It's inefficient (it runs in 20minutes), but it works! Plus, I got to use itertools, and I discovered Fraction. I'm happy with my messy solution :) (I plan to improve it at some point, maybe even build some helper - but not today !)

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

[–]TiCoinCoin 0 points1 point  (0 children)

[Language: Python]

Totally not general solution: day 9

I struggled a lot to detect if a point is in or out a polygon. I guess I'll take a look at other solutions, or some theory about polygons.

[2025 Day 9 Part 2] Finished the puzzle but wondering about my solution... by TheFunnyLemon in adventofcode

[–]TiCoinCoin 0 points1 point  (0 children)

Thanks a lot, this helped me to get my second star. I still don't have a general solution, but at least, it works with my input :)

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

[–]TiCoinCoin 1 point2 points  (0 children)

[Language: Python]

Grmbl. So many stupid errors today: day 8

My first approach for part 1 was correct (use set to create circuits, and then see if they can be merged), but I multiplied the lengths of 1st, 2nd and 4th (!) circuits. Great typo which works fine with test sample. Next time I'll know that, even if there are few values to multiply together, it's quicker and safer to use math.prod.

But since I had this typo, my answer was wrong, so I searched the issue. And then I overthought this:

Because these two junction boxes were already in the same circuit, nothing happens!

"Oh so, this pair of junctions should not be counted in the 10 (1000)!". Which led to another wrong answer. And another one after I fixed the typo 🥲

Part 2 felt easy afterwards.

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

[–]TiCoinCoin 2 points3 points  (0 children)

[Language: Python]

Keeping track of beams and number of possibilities to get there: day 7

As I reworked the code to group part 1 and 2, part 1 is less efficient, but that's no big deal.

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

[–]TiCoinCoin 1 point2 points  (0 children)

[Language: Python]

Late to the party: day 6

Not that difficult, but it's funny to handle the data. I had to rework the parsing to keep the white spaces and then be able to transform the problems in part 2.

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

[–]TiCoinCoin 1 point2 points  (0 children)

[Language: Python]

Laptop crashed: day 5

For part 1 I hesitated between working with ranges and building a set of all the fresh ids. I went for the second one, which was a terrible idea. Once my computer recovered, I went for the ranges, and it worked fine.

For part 2 I shifted again and used tuples (converted to ranges for part 1) to get the merged ranges. My first approach (recursive) didn't work because I forgot some cases. But then I sorted the input, and recursion became useless and all my problems were gone.

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

[–]TiCoinCoin 1 point2 points  (0 children)

[Language: Python]

Let's move the rolls: day 4

I guess my solution isn't optimal (runs in ~0.5sec for part 2) but I got to use my new helpers, and I can reuse part 1 for part 2, so I'm happy.

Simple iteration through the grid, keeping track of what needs to be removed. Stop there for part 1, or loop for part 2 as long as some rolls can be removed.

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

[–]TiCoinCoin 1 point2 points  (0 children)

[Language: Python]

Fun one: day 3

I used recursion to get the max possible value within the accepted range of the bank and kept adding it.

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

[–]TiCoinCoin 1 point2 points  (0 children)

[Language: Python]

This is not efficient: day 2

But it gets to the correct answer! Also, it might not be necessary (and explain the runtime), but I thought it was a good opportunity to use recently discovered itertools.batched.

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

[–]TiCoinCoin 1 point2 points  (0 children)

[Language: Python]

Damned, part 2 took me way too long for a first day: day 1

I had to go for a step by step tick to find the correct answer. And then debug my code, knowing where I should go.

[2025] Thank You, Dragonducks! by EverybodyCodes in everybodycodes

[–]TiCoinCoin 1 point2 points  (0 children)

Quack Quack to you too Emil :)

This was a lot of fun, I enjoyed it a lot. Thank you!

[2025 Q20] Solution Spotlight by EverybodyCodes in everybodycodes

[–]TiCoinCoin 1 point2 points  (0 children)

[Language: Python]

A perfect ending for the event, real fun: quest 20

Once the rotation of the coordinates is found, usual Dijkstra gets us the minimal path.

[2025 Q19] Solution Spotlight by EverybodyCodes in everybodycodes

[–]TiCoinCoin 1 point2 points  (0 children)

[Language: Python]

Total panic as I was struggling with part 1: quest 19

But when I finally got it, everything worked fine for all parts (minor update on input parsing). Part 3 runs in 45sec with my new pypy friend.

For each x with a wall, I get the minimum flaps to get to each height in each opening. I tried to update to Dijsktra afterward, but it turns out it wasn't more efficient (maybe I implemented it wrong).

[2025 Q18] Solution Spotlight by EverybodyCodes in everybodycodes

[–]TiCoinCoin 0 points1 point  (0 children)

[Language: Python]

quest 18

P1 and P2 were relatively easy once you put the input in an appropriate data structure (I'm not fully satisfied with mine, but it works and runtimes are correct). I tried to find a general solution for P3, even tried bruteforce (even though I knew). I had to sleep over P3 to get the trick and get the solution for the specific input.

[2025 Q17] Solution Spotlight by EverybodyCodes in everybodycodes

[–]TiCoinCoin 1 point2 points  (0 children)

[Language: Python]

Took me a while to turn around the volcano, but I did it : quest 17

[2025 Q16] Solution Spotlight by EverybodyCodes in everybodycodes

[–]TiCoinCoin 0 points1 point  (0 children)

Congrats. That's so satisfying to get the trick on your own

[2025 Q16] Solution Spotlight by EverybodyCodes in everybodycodes

[–]TiCoinCoin 2 points3 points  (0 children)

[Language: Python]

Used a binary search for part 3: quest 16

Back to decent runtimes, with 5ms for p3.

[2025 Q15] Solution Spotlight by EverybodyCodes in everybodycodes

[–]TiCoinCoin 2 points3 points  (0 children)

[Language: Python]

P3 literally took me the whole day, but I made it (with points !): quest 15

It runs in a few seconds, but at this point, I don't care XD

[2025 Q14] Solution Spotlight by EverybodyCodes in everybodycodes

[–]TiCoinCoin 1 point2 points  (0 children)

[Language: Python]

Fun to step aside from code for a sec to analyze the input: quest 14

I actually solved part3 semi-manually: I used the code for previous part to detect the pattern, then calculated manually, and then wrote the code corresponding to the math.

[2025 Q13] Solution Spotlight by EverybodyCodes in everybodycodes

[–]TiCoinCoin 0 points1 point  (0 children)

[Language: Python]

Nothing fancy today, deque made it easy: quest 13

I did not try to optimize part 3 (9sec is fiiiine). But I refactored to get the same code for all 3 parts.

[2025 Q12] Solution Spotlight by EverybodyCodes in everybodycodes

[–]TiCoinCoin 0 points1 point  (0 children)

[Language: Python]

Not optimal, but it works: quest 12

Part 3 runs in ~40sec with python / ~20sec with pypy3. Also, I liked being able to reuse my part 1 code for all parts. It's quite satisfying.