Advent of Code: adventofcode.com/ Rust Adventure Discord advent of code channel: / discord The code from the video (and more): github.com/Chr...
Пікірлер: 28
@Darthspudjohal2 ай бұрын
glad I found this! I've just done today's and I'm planning on using these challenges as my way to learn Rust, so it'll be good to have these to refer to after I try!!
@jackn2 ай бұрын
my favorite part of the year! love this series
@nite_owl_was_here2 ай бұрын
i like the new profile picture, makes your channel stand out more!
@chrisbiscardi2 ай бұрын
Thanks, figured it was past time to actually set a thumbnail for the channel
@salvadorguntherr96732 ай бұрын
Heyyyy nice. The goat done uploaded. Im not gonna watch it now tho cuz i did it in Python a few hours ago. Went to sleep woke up to check other Python solutions... and want to try it Rust now before i see how a Rust genius like you completed it.
@chrisbiscardi2 ай бұрын
good luck!
@31redorange082 ай бұрын
For part 2, you could've created a map for the counts. Your solution is O(n²), I guess.
@chrisbiscardi2 ай бұрын
if you check the repo, that is already one of the options implemented and benchmarked
@31redorange082 ай бұрын
@chrisbiscardi The entry() stuff is nice. 👌
@chrisbiscardi2 ай бұрын
@@31redorange08 agreed. the entry api is very, very nice.
@flwi2 ай бұрын
@@chrisbiscardicool - didn't know about that one. Looks quite nice imo and almost like something you'd find in an fp language.
@chrisbiscardi2 ай бұрын
@@flwi yeah there's a few "fp-inspired" things in Rust that aren't strict APIs or traits. For example, Functors kind of exist, but its just a .map convention on containers and not enforced by anything
@arcane33272 ай бұрын
I did it in Java earlier today. I went with the same ideas (2 lists, push all, sort, calculate and sum), but i did it more imperative :)
@WhiteSponge2 ай бұрын
Let's gooooooooo
@dobleuber2 ай бұрын
Hey thanks for this setup, I need to learn how to use it, but you did a fantastic job! Thanks
@RoamingAdhocrat2 ай бұрын
I completed it in Rust with a function to parse columns, a function to compute total difference and a function to compute similarity... and I had enough trouble setting up a build system that's future-proofed for the next three weeks. Might have to clone your repo just for the snazzy build system!
@Drezaem552 ай бұрын
For part 1 you had a lot of code to track if all numbers are ascending or descending. Instead of all that, I took the absolute of the sum of all differences and checked if it was equal to the sum of all absolute differences. If all are ascending or descending these are equal. Perhaps it could be of help in later problems :)
@awdsqe1232 ай бұрын
Instead of `(l-r).abs()` I used `l.abs_diff(r)`, probably the same, but it felt nicer somehow. Also, used the example in the hashmap entry function to make a hashmap for part 2.
@chrisbiscardi2 ай бұрын
ah abs_diff is nice. I'll probably switch to using that. Better communicates intent. I also went back and did the hashmap for part two, in addition to some other variations: github.com/ChristopherBiscardi/advent-of-code/tree/bc5ad528576194355f2fb1b6a03091d8bcd69f76/2024/rust/day-01/src
@ferdynandkiepski50262 ай бұрын
Might not be the same. L-R might lead to an overflow in certain cases. While abs_diff should be implemented in a way that avoids potential over/underflows.
@TankorSmash2 ай бұрын
That is a quality thumbnail!
@MisererePart2 ай бұрын
Instead of managing input retrieval manually i use crate emergence, which simplify a lot this part.
@chrisbiscardi2 ай бұрын
nice, there's also cargo-aoc
@laundmo2 ай бұрын
looking at your dependency list, and then the fact i've done day 1 on the rust playground in like, 8 minutes... like you probably need it later but its kinda hilarious for this easy early stuff
@chrisbiscardi2 ай бұрын
@@laundmo the dependency list *is* for later, as usual
@xorlop2 ай бұрын
Could you please share why you are not committing the inputs? I am not sure if I should follow suit and I don't understand why not.
@chrisbiscardi2 ай бұрын
tldr; there's some wording that got added partway through the event last year to the about page that caused me to get quite a bit of drive-by comments from people I've never seen again about having the inputs in the repo and I just don't want to deal with it again this year. I think its an ill-conceived attempt to stop people from copying the advent of code site... but people who are going to do that can already create multiple accounts and download the inputs anyway so it really just makes it harder for me and people who are trying to play/check that solutions work in general and not just on specific inputs. Here's the link if you want to make your own decision about it: adventofcode.com/2024/about
@JoQeZzZ2 ай бұрын
The creator has asked people not to commit the inputs because he doesn't want people to data mine over multiple inputs and figure out how they're generated