Advent of Code 2024 | Day 09 "Disk Fragmenter"

  Рет қаралды 2,969

HyperNeutrino

HyperNeutrino

Күн бұрын

Пікірлер: 14
@vegeta3993
@vegeta3993 Күн бұрын
I got through part one but got stumped on part 2 because I was passing the example but my answer was too high. After seeing your solution I see that while looking at the positions of the blanks I did not handle the case of the position of the blank being after the file position (the if start >= pos check in the while loop). For both cases I did not actually move the files, but rather calculated the checksums there by using the index it would be moved to. I modified the blank spaces the same way though - shrink them if len(file) < len(blank) or pop if len(file) == len(blank)
@oldmajor5240
@oldmajor5240 2 күн бұрын
nice! I wrote a really dumb solution naively creating the entire string and simulating everything as said in the problem. to deal with the ids, I just used unicode characters😂😅
@BillyNix
@BillyNix 2 күн бұрын
I can't believe I forgot that the dense representation had the sizes of spaces and files. I was following the example representation. Glad to see you implemented what I realized after I had already submitted my answer.
@MrRys
@MrRys 2 күн бұрын
nice solution, I saved the memory as pairs of id(blank id=-1) and size, and then just switched the ids and sizes in a loop
@Skromez
@Skromez 2 күн бұрын
hey HyperNeutrino, thank you for sharing your solutions with detailed explanation, i'm sometimes struggling with problems like these, it's easier for me to actually try to modify input to the expected result to make sure i'm doing everything correct, but sometimes that just makes things worse, but your explanation is really helpful to approach the problem from other direction and just coming up with correct data structures, really appreciate it!
@bencered
@bencered 2 күн бұрын
Awesome stuff! This solution is a lot more efficient than mine... (Took about an hour to run)
@griffinbaker860
@griffinbaker860 2 күн бұрын
here's the gaussian solution for the last part for anyone curious: *SPOILER* print( sum(fid * size * (pos + pos + size - 1) // 2 for fid, (pos, size) in files.items()) )
@yajusgakhar6969
@yajusgakhar6969 2 күн бұрын
My solution was (for part 1): Make an array of all the files, Start adding (val * index) If find a blank, add the (last element * index) As you add the values, pop them out of the list Essentially blank meant add from behind or the end of the list Still fixing my logic for part 2
@terryaney73
@terryaney73 Күн бұрын
You ever post your run times? Curious how much slower my typescript version runs compared to your python :)
@hyper-neutrino
@hyper-neutrino Күн бұрын
i could consider benchmarking but i don't have a reliable and consistent setup for that but i could. also your solution is probably faster, JS/TS is significantly faster than python in my experience
@kedarshinde4216
@kedarshinde4216 2 күн бұрын
very unrelated but what font do you use in vscode it looks cool
@hyper-neutrino
@hyper-neutrino 2 күн бұрын
that's monaspace krypton: monaspace.githubnext.com/
@SqueezeWizard
@SqueezeWizard 15 сағат бұрын
For part 2, I think blanks = blanks[:i] is basically useless (doesn't really make it faster), but blanks.pop(i) makes it like 10x faster! nice, i wasn't expecting it
Advent of Code 2024 | Day 10 "Hoof It"
15:54
HyperNeutrino
Рет қаралды 1,7 М.
Advent of Code 2024 | Day 11 "Plutonian Pebbles"
9:11
HyperNeutrino
Рет қаралды 2,4 М.
黑天使被操控了#short #angel #clown
00:40
Super Beauty team
Рет қаралды 53 МЛН
Chain Game Strong ⛓️
00:21
Anwar Jibawi
Рет қаралды 25 МЛН
Quando A Diferença De Altura É Muito Grande 😲😂
00:12
Mari Maria
Рет қаралды 34 МЛН
Advent of Code 2024 in Bash: Day 1 - Historian Hysteria
29:45
You Suck at Programming
Рет қаралды 2,9 М.
Ladybird browser update (November 2024)
13:03
Ladybird
Рет қаралды 26 М.
🎄 Advent of code 2024 in F# - day 02
26:50
Jo Van Eyck
Рет қаралды 484
Destroying everyone else in Advent of Code 2021 Day 22
19:08
Neal Wu
Рет қаралды 265 М.
How a Microcontroller starts
28:49
Artful Bytes
Рет қаралды 56 М.
Keynote: Advent of Code, Behind the Scenes - Eric Wastl
46:01
Day 2 | Advent of Code 2024 | Better Time Complexity
15:14
Errichto Algorithms
Рет қаралды 10 М.
Day 10: Hoof It | Advent of Code 2024
16:26
William Y. Feng
Рет қаралды 785
day 09 - advent of code 2024 in rust
18:48
chris biscardi
Рет қаралды 876
黑天使被操控了#short #angel #clown
00:40
Super Beauty team
Рет қаралды 53 МЛН