day 04 - advent of code 2024 in rust

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


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

the low hanging fruit optimization i used was when i had my kernel/window go over to find the start letter in part 2 I did as you know that it will never be on an edge and then you can skip the check for edge conditions

smellyfis
Автор

For the directions on part 1, it'd be easier and maybe faster to use multipliers than make a bunch of IVec2's, What I ended up doing is a Vec of all the directions starting counterclockwise from the origin ('X') then iter on a range of 1..4 and multiply that by each direction + the offset of the origin (the row and col positions) and then checked just like you did but at index [multiplier - 1]

haemolacriaa
Автор

For part 1 I just resorted to collecting all the rows, cols and both diagonals into a single Vec<String> with diagonals, then just counting all of the occurrences using a window function on "XMAS".len() and then filtering whether the slice matches "XMAS". Then you just count :) This time part 2 was way easier than part 1.

narigoncs
Автор

It's just day 4 but the solution is unable to follow for me 😞

avalagum
Автор

nice one! I had a small typo in the directions matcher (nw vs sw) and it took ~1h to find it :-/
For some reason I very often have bugs in the days where we have to deal with coordinates and directions. Especially since the y-direction in computer-world is different from y-direction in our world. You stare at the debug output and think everything's fine, but it isn't ;-)

flwi
Автор

you could also simply put it put par_iter into some places for faster execution :D

cat_or_not
Автор

"straight forward easy to Cut to m sitting here confused af...😂. Yea ima stay skipped on this one. I

salvadorguntherr
Автор

No views in a minute, bro really fell of

alvinn_the_real_one