Advent of Code 2023 Day 5: If You Give A Seed A Fertilizer

preview_player
Показать описание
Pretty challenging problems today, especially part 2! I'm sort of surprised considering it's only day 5 and it's not a weekend.

0:00 Intro
2:00 Part 1
7:21 Codecrafters Promotional Segment
9:18 Part 2

(Disclaimer: I receive commissions on paid memberships through my link, but Codecrafters is not a sponsor of this channel, does not endorse any of my content, and does not review any of my videos.)
Рекомендации по теме
Комментарии
Автор


(Codecrafters has not sponsored this video directly and they did not have the opportunity to review any of this video, including the promotional segment.)

hyper-neutrino
Автор

What makes the explanation so good is that you print the result of most code changes. Thanks!

xxxxyyyy-llhz
Автор

Difficulty is all over the place this year. I was recommending 2022 for people who wanted to learn a new language because of the gradual difficulty increase

SharunKumar
Автор

Wow I really feel ashamed not to Even be able to complete part 1 when I see such clever solutions and so many people doing them. Thanks for the explanation

YukamsGaming
Автор

I appreciate that your are posting of your solutions here. I'm learning quite a few new Python tricks.

unclerojelio
Автор

i did everything exactly the same but then got stuck on calcualting those intersections. The idea to add back into seeds the outer parts of the interval intersection is very elegant

aaronpanaitescu
Автор

This was very helpful. I've almost given up when I saw this one and I just left the part 2 for later. I've solved it today thanks to your explanation.
I'm new to the channel but I'll deffinitely stay longer because your videos are very clear

yodua
Автор

I don't usually comment on videos, but your explanation was extremely helpful after this problem fried my brain xD. Massive props, keep doing what you're doing!

paolostet
Автор

Wow man, I managed to pull something that works today but had real performance issues (my script ran for 10000sec on part 2), you provides really good insights on Python in your explanation and I see I have much space for improvment. Keep up the good work and thx very much !

MrRoms
Автор

Great video! Excellent solution which is both simple to understand and also sophisticated. I had already spent around 6 hours trying to work through part 2 and kept getting close but not quite there yet. Your drawings really helped visualize the problem as well. Subbed and looking forward to the rest of your 2023 videos!

timothyhumphreys
Автор

I appreciate the drawings of the intersections they really helped visualise the problem, I did it using the start and length rather than start and end and also used recursion when the range got split into 2 and it took maybe 2-3 hours to solve but seeing your solution just makes it look so easy and elegant lol

purpleysound
Автор

I like your big-brain-words big-brain-man. Converting this to C++ will be fun...

luigidabro
Автор

Thanks, I solved it but I had an 08:22:46.998 run I went through all the seeds as in part 1. This was enlightning.

PietWoldinga
Автор

My naive solution was not going to finish anytime soon. I watched your video and then started implementing the solution based on a vague understanding of ranges/intervals and their mapping. I was able to get the sample solution right though. Still there were issues with my final implementation. I rewatched the explanation for part two of this video a couple of times, still nothing. Then I saw your "short" on intervals. That gave me some idea about the calculation of offset intervals and I was able to get the offsets and limits right. I had to draw the complete mapping of intervals on paper for the sample input while debugging my code. While rewatching the video again I noticed I wasn't using the queues, as once the seed interval is split into two, the non overlapping interval needs to be mapped again. And finally I was able to get the correct answer.
Thank you for the clear explanations, nice visuals and printing out the intermediate variable values as you implemented+explained your code in the video.

atosh
Автор

Thank you. I would really love it if you can create another explainer for part 2. Preferbely by running some example numbers in excalidraw.

HeliosRSPS
Автор

Learned a few new tricks so thank you very much! My initial run at part 2 took about 2 min to complete which I thought was ok .... until I found your video and learned just how fast you can make it!

mkrichey
Автор

Thanks for sharing!
Now, I understand why my approach didn't work ... I only considered the overlap and discarded the remaining! 😅

stoufa
Автор

Great video, helped me understand how to approach the second part. One thing that could be helpful to understand what exactly are you doing and what do variables mean - could you try to use more descriptive names for variables instead of a, b, c? Like source, destination, length or something. Other than that, thank you very much!

DapsSenpai
Автор

Finally, I have finished the part 2. It took me 1 hour to do the part 1 and 8 hour to make the part 2 working even though it still takes 2 minutes for my program to solve the part 2 thanks to Rust's Release Mode (since my objective doing AOC is to learn rust). If I'm using Python, JS, or other interpreted language maybe it will be very slow.

afterschool
Автор

Thanks a lot man! The explanation was so clear

gradientO