2025 #5

Open
aey wants to merge 15 commits from 2025 into main
Owner
No description provided.
aey added 9 commits 2025-12-07 14:03:02 +00:00
Brute force, since I was to newly awake to figure out
the smart solution.
I tried to solve it without regexp at first, failed
brutally. Cut the line count by 80% using a regexp
instead.

It was also funny to get all square roots.
For the first part, I used itertools.combinations
to find the highest pairs of batteries. And as
expected, that solution did not scale well for pt 2.

I figured out that reducing batteries until the top
most 12 (and 2) remained was the correct way to go.

the _maxj(line, C) function is the hive conclusion
from the solution mega thread. I really liked this
brilliant use of a while loop to exlude batteries.

 - The first char just skip the while loop. A char
   emptying the battery list also does this.
Lost 1h in 2025 day 4 pt 1 for this. :D

Apparently, ADJ is not used that often.
Had a bug in my aoc lib, that lost me an hour for pt 1:
The ADJ dict has SW twice, and lacks NE.

The bug is at least 2 years old. It was introduced in 661f18dca4
and apparently has never worked. I guess it has not been used
up until now.

That being said, it was straight-forward. A new helper for
grid was used the first time, as well as an improved vdbg()
function.
Part 2 was too hard for me, since I initially worked
with range(s, e). It quickly became out of hand.

A funnel method was instead used.
Lost 20 minutes in pt 1 not rembering that a print()
of a zip consumes it and makes it not loopable: had
I just used list(zip()) or removed the print, I would
have had the answer in a decent time frame.

Pt 2 was fun! I first experienced with ljust() and
rjust(), only to realize the input was mixed. Instead,
I threated the input as a grid.
For part 1, BFS is used since there is no need to
visit each splitter more than once to count visited
splitters.

For part 2, the code initially removed the visited
check. This failed miserably, losing momentum aound
Y=54-56.

A recursive function with memoization solves it much
faster.
aey added 1 commit 2025-12-08 06:58:37 +00:00
For the First time this season, pt 2 was not an epic
HOLY SHIIIT!!! facemelter.

I stared at my code in disbelief during pt 1 for several
minutes before I increased the test point from from 40
to 1000 and got the right answer.
aey added 2 commits 2025-12-09 13:49:46 +00:00
Pt 2 is almost there. Need a better flood fill
algorithm.
aey added 1 commit 2025-12-09 18:27:39 +00:00
aey added 1 commit 2025-12-09 18:34:06 +00:00
aey force-pushed 2025 from 335db26ad4 to b8409db06c 2025-12-09 23:40:38 +00:00 Compare
aey added 1 commit 2025-12-11 19:45:11 +00:00
aey added 2 commits 2025-12-11 22:36:30 +00:00
For p1 a BFS algorithm is fast enough. For pt 2,
for the third day in a row, it did not work.

I caved in and used recursion and memoisation for
DFS instead, instantly fast as lightning.

I finished by making the pt 2 code compatible with
pt 1.
This pull request can be merged automatically.
You are not authorized to merge this pull request.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin 2025:2025
git checkout 2025

Merge

Merge the changes and update on Forgejo.

Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.

git checkout main
git merge --no-ff 2025
git checkout 2025
git rebase main
git checkout main
git merge --ff-only 2025
git checkout 2025
git rebase main
git checkout main
git merge --no-ff 2025
git checkout main
git merge --squash 2025
git checkout main
git merge --ff-only 2025
git checkout main
git merge 2025
git push origin main
Sign in to join this conversation.
No reviewers
No labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference: aey/advent-of-code#5
No description provided.