this post was submitted on 08 Dec 2025
24 points (100.0% liked)

Advent Of Code

1199 readers
11 users here now

An unofficial home for the advent of code community on programming.dev! Other challenges are also welcome!

Advent of Code is an annual Advent calendar of small programming puzzles for a variety of skill sets and skill levels that can be solved in any programming language you like.

Everybody Codes is another collection of programming puzzles with seasonal events.

EC 2025

AoC 2025

Solution Threads

M T W T F S S
1 2 3 4 5 6 7
8 9 10 11 12

Visualisations Megathread

Rules/Guidelines

Relevant Communities

Relevant Links

Credits

Icon base by Lorc under CC BY 3.0 with modifications to add a gradient

console.log('Hello World')

founded 2 years ago
MODERATORS
 
top 5 comments
sorted by: hot top controversial new old
[–] owenfromcanada@lemmy.ca 6 points 2 weeks ago

Did you also try to implement a sort that ended up being magnitudes less efficient than calling .sort(), or are you normal?

[–] dbx12@programming.dev 4 points 2 weeks ago

That cafeteria (I know, not day 8) was mean to my RAM.

[–] strlcpy 2 points 2 weeks ago (2 children)

What are we calling brute force here? Continuing to go through the pair list and merging groups? Is there any other way?

[–] eco_game@discuss.tchncs.de 1 points 2 weeks ago

You're right, iterating through the pairs does seem to be the way. After doing some analyzing of what takes how long, it seems my issue is with (quickly) figuring out whether I've already connected all nodes or not.

[–] Deebster@programming.dev 1 points 2 weeks ago

For part one and likely part 2 you don't need to do all 499500 comparisons, you could split the grid into boxes and only search adjacent ones. E.g. z / 10 = which decile and look at z, z-1, z+1 (and the same for x and y). Less work for the processor, more work for you, and of course, sqrt (which you can also probably skip) is so efficient on modern chips that the overhead of this eats a chunk of the benefits (depending on how low-level your language is).