this post was submitted on 06 Dec 2023
132 points (99.3% liked)

Advent Of Code

761 readers
1 users here now

An unofficial home for the advent of code community on programming.dev!

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.

AoC 2023

Solution Threads

M T W T F S S
1 2 3
4 5 6 7 8 9 10
11 12 13 14 15 16 17
18 19 20 21 22 23 24
25

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 1 year ago
MODERATORS
 
all 17 comments
sorted by: hot top controversial new old
[–] ace@lemmy.ananace.dev 28 points 11 months ago (1 children)

The naïve and unoptimized version ran in under 4 seconds for me, that's nowhere near "Time to knuckle down and actually optimize this" territory.

[–] Setarkus@lemmy.world 3 points 11 months ago

I was so confused just now thinking this was about day 5. Like "What the f do you consider naïve that takes less than four seconds??"

[–] wdx@feddit.de 23 points 11 months ago (1 children)
[–] UnRelatedBurner@sh.itjust.works 2 points 11 months ago

this is funny

[–] UlrikHD@programming.dev 15 points 11 months ago (1 children)

Too scarred from puzzle 5 to do the naïve approach anymore.

[–] Black616Angel@feddit.de 6 points 11 months ago

Dude, 5 was so weird, I didn't even recognize a hard or easy approach.

[–] ThrowawayPermanente@sh.itjust.works 11 points 11 months ago

Math is something computers know how to do. I know how to do For Each loops.

[–] Diplomjodler@feddit.de 3 points 11 months ago (2 children)

Just use dictionaries in Python. Never worry about search performance any more.

[–] bob_lemon@feddit.de 11 points 11 months ago* (last edited 11 months ago) (2 children)

I mean, that literally failed just yesterday.

Also I'm not sure where in today's problem you would even use a dictionary

[–] Zagorath@aussie.zone 1 points 11 months ago (1 children)

Hey, I haven't been doing Advent this year. What was day 5's problem and why did dicts fail?

[–] bob_lemon@feddit.de 3 points 11 months ago (1 children)

There was a series of number ranges that mapped onto other ranges. The simple approach was filling dictionaries, which worked well for the example data. In the actual data, there ranges were much much larger (in the 100,000,000's), which made the dictionaries prohibitively large.

[–] Faresh@lemmy.ml 1 points 11 months ago

If each number was 8 bytes wide, it would require, if I didn't mess up my math, 18 GB to fully represent all seeds/numbers as an array.

[–] perviouslyiner@lemm.ee 3 points 11 months ago* (last edited 11 months ago)

progamming ↑↱ excel

[–] soulsource@discuss.tchncs.de 3 points 11 months ago

There is a trap in part 2, by the way, that can trip people who try to use maths:

SpoilerThe values are so large that if one uses single precision (32 bit) floating point values, the result will not be correct. Double precision floats yield the correct result.

This means, that doing integer calculations isn't as bad as it sounds at first.