day 01 - advent of code 2024

  Рет қаралды 14,379

chris biscardi

chris biscardi

Күн бұрын

Advent of Code: adventofcode.com/
Rust Adventure Discord advent of code channel: / discord
The code from the video (and more): github.com/Chr...

Пікірлер: 28
@Darthspudjohal
@Darthspudjohal 2 ай бұрын
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!!
@jackn
@jackn 2 ай бұрын
my favorite part of the year! love this series
@nite_owl_was_here
@nite_owl_was_here 2 ай бұрын
i like the new profile picture, makes your channel stand out more!
@chrisbiscardi
@chrisbiscardi 2 ай бұрын
Thanks, figured it was past time to actually set a thumbnail for the channel
@salvadorguntherr9673
@salvadorguntherr9673 2 ай бұрын
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.
@chrisbiscardi
@chrisbiscardi 2 ай бұрын
good luck!
@31redorange08
@31redorange08 2 ай бұрын
For part 2, you could've created a map for the counts. Your solution is O(n²), I guess.
@chrisbiscardi
@chrisbiscardi 2 ай бұрын
if you check the repo, that is already one of the options implemented and benchmarked
@31redorange08
@31redorange08 2 ай бұрын
@chrisbiscardi The entry() stuff is nice. 👌
@chrisbiscardi
@chrisbiscardi 2 ай бұрын
@@31redorange08 agreed. the entry api is very, very nice.
@flwi
@flwi 2 ай бұрын
@@chrisbiscardicool - didn't know about that one. Looks quite nice imo and almost like something you'd find in an fp language.
@chrisbiscardi
@chrisbiscardi 2 ай бұрын
@@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
@arcane3327
@arcane3327 2 ай бұрын
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 :)
@WhiteSponge
@WhiteSponge 2 ай бұрын
Let's gooooooooo
@dobleuber
@dobleuber 2 ай бұрын
Hey thanks for this setup, I need to learn how to use it, but you did a fantastic job! Thanks
@RoamingAdhocrat
@RoamingAdhocrat 2 ай бұрын
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!
@Drezaem55
@Drezaem55 2 ай бұрын
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 :)
@awdsqe123
@awdsqe123 2 ай бұрын
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.
@chrisbiscardi
@chrisbiscardi 2 ай бұрын
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
@ferdynandkiepski5026
@ferdynandkiepski5026 2 ай бұрын
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.
@TankorSmash
@TankorSmash 2 ай бұрын
That is a quality thumbnail!
@MisererePart
@MisererePart 2 ай бұрын
Instead of managing input retrieval manually i use crate emergence, which simplify a lot this part.
@chrisbiscardi
@chrisbiscardi 2 ай бұрын
nice, there's also cargo-aoc
@laundmo
@laundmo 2 ай бұрын
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
@chrisbiscardi
@chrisbiscardi 2 ай бұрын
@@laundmo the dependency list *is* for later, as usual
@xorlop
@xorlop 2 ай бұрын
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.
@chrisbiscardi
@chrisbiscardi 2 ай бұрын
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
@JoQeZzZ
@JoQeZzZ 2 ай бұрын
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
day 02 - advent of code 2024
24:45
chris biscardi
Рет қаралды 4,5 М.
12 months with the Bevy Game Engine - This Year in Bevy 2024
9:23
chris biscardi
Рет қаралды 10 М.
Арыстанның айқасы, Тәуіржанның шайқасы!
25:51
QosLike / ҚосЛайк / Косылайық
Рет қаралды 700 М.
REAL or FAKE? #beatbox #tiktok
01:03
BeatboxJCOP
Рет қаралды 18 МЛН
The Best Band 😅 #toshleh #viralshort
00:11
Toshleh
Рет қаралды 22 МЛН
What P vs NP is actually about
17:58
Polylog
Рет қаралды 149 М.
Inside the V3 Nazi Super Gun
19:52
Blue Paw Print
Рет қаралды 3,2 МЛН
You Should Really Know These Traits in Rust
18:36
Oliver Jumpertz
Рет қаралды 19 М.
Keynote: Advent of Code, Behind the Scenes - Eric Wastl
46:01
All Rust features explained
21:30
Let's Get Rusty
Рет қаралды 342 М.
5 deadly Rust anti-patterns to avoid
13:25
Let's Get Rusty
Рет қаралды 41 М.
The case for sans-io
24:09
fasterthanlime
Рет қаралды 28 М.
Catching up with async Rust
17:55
fasterthanlime
Рет қаралды 32 М.
A Simpler Way to See Results
19:17
Logan Smith
Рет қаралды 128 М.