day 09 - advent of code 2024 in rust

preview_player
Показать описание


Рекомендации по теме
Комментарии
Автор

I am doing advent of code for the first time in Rust. It has been incredible to watch your solutions after giving it a go myself. I am learning so many of the std Rust APIs as well as some additional library APIs. Thanks so much for doing this! I also stole your benchmarking code which is awesome and gives me some solid insight on if my solutions are reasonable. Today was the first day my benchmark was on the same order of magnitude as yours! (I also spent many many hours on this one)

jimhillr
Автор

For Part 1 I used swap_remove on a vec of Option<u32>. Probably not the fastest, but it does mean that the file compacting logic only consists of a while loop with a single line in it.

stefanv.i
Автор

12:24 NINE NINE!!!! (in my best Terry Crews voice)

NickyTheRook
Автор

This one took me much longer than I care to admit... not because it was hard to conceptualize a solution, but rather due to me consistently making bugs for myself. Here's hoping that tomorrow, I will be able to get it done in a much more reasonable time.

jl
Автор

Nice to see the usage of iterators but I was hoping to see you solve it by expanding the disk map into a Vec<i32> e.g 12345 would be vec![0, -1, -1, 1, 1, 1, -1, -1, -1, -1, 2, 2, 2, 2, 2] and then using the two pointers. I got something working with Python but struggling with the Rust version.

bulkan.evcimen
Автор

I'm not even trying to understand this code, it's too convoluted. I've preprocessed the data into
struct Block {
ind: usize,
files: u16,
space: u16,
moved: bool,
}
and it makes further work so much easier. My answer is still wrong though which is odd.

adsick_ua
Автор

For some reason, I actually get the wrong answer from your solution with my input data for part 1. I was stuck so long in this that my part 2 is super unoptimized and runs around 200x slower than the part 1 solution x_x

Dilaz