- Видео 334
- Просмотров 308 333
0xdf
США
Добавлен 20 окт 2018
Code Chronicle [Day 25 - Advent of Code 2024 - Python]
I'm given visual blocks showing both locks and keys. I'll need to process all of them and then test each to see how many pairs of lock / key exist where the key fits into the lock.
2024 AOC repo: gitlab.com/0xdf/aoc2024/
2024 AOC Intro video: ruclips.net/video/4XKZZrhhiQE/видео.html
VSCode Debug video: ruclips.net/video/cNhtk2Ob4B8/видео.html
☕ Buy Me A Coffee: www.buymeacoffee.com/0xdf
[00:00] Part1 introduction
[01:57] Input review
[02:36] Processing input to blocks
[08:10] Brute-forcing locks and keys
[09:24] Solving part 1 example
[09:47] Fixing read in bug
[10:40] Solving part 1
[11:06] Conclusion
#adventofcode #python
2024 AOC repo: gitlab.com/0xdf/aoc2024/
2024 AOC Intro video: ruclips.net/video/4XKZZrhhiQE/видео.html
VSCode Debug video: ruclips.net/video/cNhtk2Ob4B8/видео.html
☕ Buy Me A Coffee: www.buymeacoffee.com/0xdf
[00:00] Part1 introduction
[01:57] Input review
[02:36] Processing input to blocks
[08:10] Brute-forcing locks and keys
[09:24] Solving part 1 example
[09:47] Fixing read in bug
[10:40] Solving part 1
[11:06] Conclusion
#adventofcode #python
Просмотров: 181
Видео
Crossed Wires [Day 24 - Advent of Code 2024 - Python]
Просмотров 23714 часов назад
For day 24, I'm given a series of wires connecting to OR, AND, and XOR gates, and some initial values. Part 1 is very easy to recursively trace back from the given endpoints to find their values. In part 2, I have to swap four pairs of gate outputs to make it so that the result is the binary value representing the addition of two 45-bit binary inputs. This is very challenging, and involves some...
LAN Party [Day 23 - Advent of Code 2024 - Python]
Просмотров 16416 часов назад
I'm given a list of connections each showing two connected computers. I'll first need to identify triplets, three computers where each is connected to the other two. In part two, I'll use recusion to find the largest fully connected group. 2024 AOC repo: gitlab.com/0xdf/aoc2024/ 2024 AOC Intro video: ruclips.net/video/4XKZZrhhiQE/видео.html VSCode Debug video: ruclips.net/video/cNhtk2Ob4B8/виде...
Monkey Market [Day 22 - Advent of Code 2024 - Python]
Просмотров 229День назад
I'm given seeds to a pseudo random number generation algorithm, and asked to find the 2000th number for each, and then asked to look for patterns in the differences. 2024 AOC repo: gitlab.com/0xdf/aoc2024/ 2024 AOC Intro video: ruclips.net/video/4XKZZrhhiQE/видео.html VSCode Debug video: ruclips.net/video/cNhtk2Ob4B8/видео.html ☕ Buy Me A Coffee: www.buymeacoffee.com/0xdf [00:00] Part1 introduc...
Keypad Conundrum [Day 21 - Advent of Code 2024 - Python]
Просмотров 336День назад
I'm giving commands to a robot that's commanding a robot that's commanding a robot to work a keypad! It's complicated! In part two, the same, but with 25 robots! 2024 AOC repo: gitlab.com/0xdf/aoc2024/ 2024 AOC Intro video: ruclips.net/video/4XKZZrhhiQE/видео.html VSCode Debug video: ruclips.net/video/cNhtk2Ob4B8/видео.html ☕ Buy Me A Coffee: www.buymeacoffee.com/0xdf [00:00] Part1 introduction...
Race Condition [Day 20 - Advent of Code 2024 - Python]
Просмотров 222День назад
I'm given a maze to work through, which is very easy. But, then I'm told I'm allowed a single shortcut of length two, effectively once walking through a wall, and I need to find the number of shortcuts that improve my time by at least 100 steps. I'll create a map of each position that can be visited and compare each pair of points to see if a shortcut is possible. In part 2, I'm allow to go thr...
Linen Layout [Day 19 - Advent of Code 2024 - Python]
Просмотров 19714 дней назад
I'm given a list of patterns, and then a bigger list of much bigger patterns. For each bigger pattern, I first need to figure out if I can make it from some combination of the smaller patterns. Then I need to figure out how many ways I can make it from the smaller patterns. I'll use recursion and caching to solve this relatively quickly. 2024 AOC repo: gitlab.com/0xdf/aoc2024/ 2024 AOC Intro vi...
RAM Run [Day 18 - Advent of Code 2024 - Python]
Просмотров 22814 дней назад
I'm giving a list of RAM blocks that will fill up a plane. I need to find a path through the maze with a given number of blocked in place. In part two, I'll use binary search to find the point in less than a second. 2024 AOC repo: gitlab.com/0xdf/aoc2024/ 2024 AOC Intro video: ruclips.net/video/4XKZZrhhiQE/видео.html VSCode Debug video: ruclips.net/video/cNhtk2Ob4B8/видео.html ☕ Buy Me A Coffee...
Chronospatial Computer [Day 17 - Advent of Code 2024 - Python]
Просмотров 55314 дней назад
This challenge involves coding a computer to handle 3 bit instructions and operands. In part two, I'll do some targetted brute force to find the correct input. Dikstra's algorithm: en.wikipedia.org/wiki/Dijkstra's_algorithm 2024 AOC repo: gitlab.com/0xdf/aoc2024/ 2024 AOC Intro video: ruclips.net/video/4XKZZrhhiQE/видео.html VSCode Debug video: ruclips.net/video/cNhtk2Ob4B8/видео.html ☕ Buy Me ...
Reindeer Maze [Day 16 - Advent of Code 2024 - Python]
Просмотров 31814 дней назад
I'm given a maze with a start and end with many ways to get between them. There's a cost to step forward and a much larger cost to turn. I'm asked for part 1 to find the least cost to get from start to end. In part 2, I need to find a count of the spaces included in any of the paths that have the lowest cost. I'll use Dijkstra's algorithm to solve both, adding additional state for the second pa...
Wearhouse Woes [Day 15 - Advent of Code 2024 - Python]
Просмотров 22914 дней назад
I'm given a grid representing a wearhouse with a robot that is pushing crates around. In part two everything gets wider and more complex. 2024 AOC repo: gitlab.com/0xdf/aoc2024/ 2024 AOC Intro video: ruclips.net/video/4XKZZrhhiQE/видео.html VSCode Debug video: ruclips.net/video/cNhtk2Ob4B8/видео.html ☕ Buy Me A Coffee: www.buymeacoffee.com/0xdf [00:00] Part1 introduction [01:30] Setup / data ov...
Restroom Redoubt [Day 14 - Advent of Code 2024 - Python]
Просмотров 23414 дней назад
I'm given a list of robots each with x, y positions and velocity. In part 1, I need to get the position of every robot after 100 seconds, and calculate a score based on the quadrant the robot falls into. For part 2, I'm asked to find when the robots line up to form the shape of a Christmas tree. This is a rather silly problem, but I'll find it by plotting the safety score over time and seeing a...
Claw Contraption [Day 13 - Advent of Code 2024 - Python]
Просмотров 28314 дней назад
I'm given details for a bunch of games that I can map into a system of two linear equations. I'll use Cramer's Rule to solve this very easily, both part 1 and part 2. Cramer's Rule: en.wikipedia.org/wiki/Cramer's_rule 2024 AOC repo: gitlab.com/0xdf/aoc2024/ 2024 AOC Intro video: ruclips.net/video/4XKZZrhhiQE/видео.html VSCode Debug video: ruclips.net/video/cNhtk2Ob4B8/видео.html ☕ Buy Me A Coff...
Garden Groups [Day 12 - Advent of Code 2024 - Python]
Просмотров 36621 день назад
I'm given a grid with each point representing a type of crops. I'll need to find each contiguous region of the same crop, and then calculate the the cost to fence in that region. In part one, that's the size of the region times the perimeter. In part two, it's the size times the number of sizes on the region. I'll count sides by counting corners. 2024 AOC repo: gitlab.com/0xdf/aoc2024/ 2024 AOC...
Plutonian Pebbles [Day 11 - Advent of Code 2024 - Python]
Просмотров 39421 день назад
I'm given a list of numbers. At each iteration (blink), a stone either splits in two or has it's value change. This leads to expoential growth in the length of the list. In part 1, I just follow the rules and track the list. In part two, I'll use a recursive cached function to let the calculation happen in reasonable time. 2024 AOC repo: gitlab.com/0xdf/aoc2024/ 2024 AOC Intro vide: ruclips.net...
Hoof It [Day 10 - Advent of Code 2024 - Python]
Просмотров 28821 день назад
Hoof It [Day 10 - Advent of Code 2024 - Python]
Disk Fragmenter [Day 9 - Advent of Code 2024 - Python]
Просмотров 38721 день назад
Disk Fragmenter [Day 9 - Advent of Code 2024 - Python]
Resonant Collinearity [Day 8 - Advent of Code 2024 - Python]
Просмотров 30521 день назад
Resonant Collinearity [Day 8 - Advent of Code 2024 - Python]
Bridge Repair [Day 7 - Advent of Code 2024 - Python]
Просмотров 32621 день назад
Bridge Repair [Day 7 - Advent of Code 2024 - Python]
Guard Gallivant [Day 6 - Advent of Code 2024 - Python]
Просмотров 54021 день назад
Guard Gallivant [Day 6 - Advent of Code 2024 - Python]
Print Queue [Day 5 - Advent of Code 2024 - Python]
Просмотров 42828 дней назад
Print Queue [Day 5 - Advent of Code 2024 - Python]
Ceres Search [Day 4 - Advent of Code 2024 - Python]
Просмотров 51228 дней назад
Ceres Search [Day 4 - Advent of Code 2024 - Python]
Mull It Over [Day 3 - Advent of Code 2024 - Python]
Просмотров 63528 дней назад
Mull It Over [Day 3 - Advent of Code 2024 - Python]
Chrome Local Overrides [Snowball Showdown - Sans Holiday Hack 2024]
Просмотров 390Месяц назад
Chrome Local Overrides [Snowball Showdown - Sans Holiday Hack 2024]
PowerShell Challenge [Sans Holiday Hack 2024]
Просмотров 667Месяц назад
PowerShell Challenge [Sans Holiday Hack 2024]
Red-Nosed Reports [Day 2 - Advent of Code 2024 - Python]
Просмотров 825Месяц назад
Red-Nosed Reports [Day 2 - Advent of Code 2024 - Python]
Historian Hysteria [Day 1 - Advent of Code 2024 - Python]
Просмотров 1,5 тыс.Месяц назад
Historian Hysteria [Day 1 - Advent of Code 2024 - Python]
Paper Shreds Easter Egg [Sans Holiday Hack 2024]
Просмотров 509Месяц назад
Paper Shreds Easter Egg [Sans Holiday Hack 2024]
Brute Forcing a Web Pin - Frosty Keypad [Sans Holiday Hack 2024]
Просмотров 527Месяц назад
Brute Forcing a Web Pin - Frosty Keypad [Sans Holiday Hack 2024]
Incredibly smart stuff and presented straightforwardly. You're a gem.
wow, this make my brain blow.
Thank you so much for this amazing video! A bit off-topic, but I wanted to ask: I have a SafePal wallet with USDT, and I have the seed phrase. (alarm fetch churn bridge exercise tape speak race clerk couch crater letter). What's the best way to send them to Binance?
Hey man, not sure how I stumbled upon your page a while ago. Haven't watched many videos but def plan on going through them to learn how to approach boxes/challenges. I was wondering, what did you do to get to the point where you can tackle any box and challenge? Where did it start? I started with IT and not Comp Sci, so I'm slowly learning this stuff in my free time more as a hobby. Curious to hear your journey. Maybe you have a video? Thanks!
Thanks for sharing, always learn a lot watching your code sessions.
Hellloooo!
First
Think you can just do max(dict.values()) but other than that great. Waiting for your day 23 - 25 solution! happy christmas
Ha! Of course! Thanks. Hopefully will get the last three videos done tomorrow
Nice video, but there is no actual explanation of how to get modname or getattr(app). in your case you just ran a simplified app, got 3 different names and one of them magically worked. After searching online I wasn't able to find any info on how to get it.
Here is how I did part 2: I figured that Christmas Tree should have several long horizontal lines of robots, and there should be a high degree of symmetry. So I calculated a "Symmetry Score" for each time second that measured the degree of horizontal symmetry and looked for when that symmetry score spiked up.
Ah smart. It's an interesting challenge, though I still don't like not knowing if my solution also solves other inputs.
Have really enjoyed the content for the 2024 season, looking forward to seeing how you finish the series. Have a great Holiday season.
Thank you! Hope you have a great season as well!
I'd just like to comment that I have watched most of your video's of AoC '24 up until now and I really enjoy them. This is my first time participating with AoC with the goal to bring my python skills up to a usable level :) I'm not bothered with the leaderboard at all and try to solve the puzzles first by myself and in order and then watch your corresponding video to see what solutions you came up with. (At the time of this writing I'm pondering day9 part2.) Usually this means only using about 20% of the lines I needed XD. You videos are consise, you expain your train of thought well and you explain all your considerations. Greatly appreciated!
Thank you so much for the kind words, and I'm excited to hear you're diving in. I love your approach. Try where you can, and then learn from others when you get stuck! That's a great plan to improve. And yes, I ignore the leaderboard as well. I've tried it a few times, but speed isn't necessarily my goal with these, and I'm not very fast, and it would take a lot of practice to become fast. Still, I love solving the challenges!
awesome
Great video. I was a little bit lost on the second part, so thanks for your explanation and solution 👍
Neat
thanks for the clear explanation, i was so stuck on this one!
Love the content 0xdf. Great inspiration.
0xdf casually flexing his quick math, great explanation!
hello sir, can you refer me at hackthebox> i really love it, i have completed cpts path and after my university examinations will be giving the cpts exam and also i have completed my ejpt certification
From Part 1, you know that you can get through with 1024 drops, so you can start with lo = 1024 for Part 2.
Good call, though it doesn't save that much. In fact, I think it takes the same number of cuts in half to get there because 3450 and 2426 (3450 - 1024) are both greater than 2048 and less than 4096.
How can i create the .session file? the bash script is failing at that point for me: "AOC_SESSION isn't set. Cannot continue."
From the website where you're logged in, go into the dev tools and find the cookie named session (in Chrome its in the Application tab under Cookies on the left). Save that value in a file named .session, or add a line like AOC_SESSION=[that value] to your ~/.bashrc file.
Hey! You should also just leave the debugging in the video. Personally, I feel that when I write code, its unreasonable to expect it to always work the first time. When I see others debugging code, I gain intuition on things that could go wrong or to watch out for. This gives important insight I would rather not miss. Love the interesting content! Cheers
Incase you are interested in why tuples were slower, it is because python expects addition to lists and keeps about a 2 thirds empty always to save on reallocation. But with tuples you were constantly remaking and recopying everything each time you added something to it.
Interesting! Thanks!
16:01, it would have been good if you just didnt use f strings and simply wrote print("Part 2", *part2)
Yup, good call.
Nice work!
Thanks!
if you wanna show something with your cursor, make sure to capture it.
Understood. Will try not to do that again.
I agree part 2 was annoying. I misread the problem description where it said that *most* robots would form an image and looked for a state where *all* robots were connected in one big Christmas tree, DOH! What worked for me was looping until no robots overlapped, and at least one robot had eight neighbors.
Yeah. Seems like a bad problem
Yeah this method is cool, me being thick as brick i had to create 10,000 images and then painfully going through thumbnails in the finders locate the solution lol!
Note to other viewers, my input tree is located almost in the middle of the image. This makes the safety scores not much larger/smaller than other false images. Seems like better heuristics might be necessary for cases like this. Removing "Robots that are exactly in the middle (horizontally or vertically) don't count as being in any quadrant" condition from the safety score calculation didn't help.
That sounds painful
Thanks, using the cramer's rule does make it much simpler. I solved it using just pure algebra and it wans't too pretty (had to deal with floating errors too)
Your method is super interesting. I think the theme of this question was to use topological sort O(V+E), but you've solved it using custom sort function O(nlogn). Nice use of the custom sort option (and the set it to 1 whenever the ordering is False). In terms of the sorting efficiency though not sure it would be efficient as it would have many 'equal' comparisons (harder to divide and conquer?)
Cool way to solve part 2! I just printed the first 10,000 iterations and scrolled through in VSCode while keeping an eye on the mini-map.
Cool: direct and to the point!
thanks for the videos:) learning alot. i made a bool for all allowed positions. for r,c in char_map["A"]: pos1 = bool(upleft(r,c) in char_map["S"] and downleft(r,c) in char_map["S"] and upright(r,c) in char_map["M"] and downright(r,c) in char_map["M"]) pos2 = bool(upleft(r,c) in char_map["S"] and downleft(r,c) in char_map["M"] and upright(r,c) in char_map["S"] and downright(r,c) in char_map["M"]) pos3 = bool(upleft(r,c) in char_map["M"] and downleft(r,c) in char_map["M"] and upright(r,c) in char_map["S"] and downright(r,c) in char_map["S"]) pos4 = bool(upleft(r,c) in char_map["M"] and downleft(r,c) in char_map["S"] and upright(r,c) in char_map["M"] and downright(r,c) in char_map["S"]) if pos1 or pos2 or pos3 or pos4: part2 += 1
That's great, do you solve it real time?
I don't do them when they first release (I'm asleep). I try to look at the problem, think about the solution, and then start recording. And then do the same thing with part 2. At some point they will get complex enough that I'll solve and then show a summary.
Really appreciate these walkthroughs as someone learning Python i enjoy the thought process and solutions you work through. Keep it up!
Thanks!
Hi New subsriber here , I am a beginner in python can i also like participate in this and i have just started to code learned all the topics but can i able to this type of advent of code in python ? What's your opinion on this.
The challenges at the start are great beginner challenges. Once they start ramping up in difficulty, I would expect a beginner to get really frustrated. That said, I think you could learn a ton watching someone else's solutions, and not just watching idly, but working along, making sure you understand everything that's happening.
@0xdf thanks , I will be doing as you say, By actively engaging and watching solutions.
I think it can be made more efficient if you cache number of 9 pos that can be reached at any given position. Great video thanks!
Yes, totally agree.
Great video thanks. just wanna point out that we can't see the mouse pointer in the video so when you address something using the mouse pointer it can be hard to follow. Other than that thanks!
Ah, thanks for the heads up. Will try to do better!
Thanks you so much! Your solution using regex is SO much cleaner than mine... :D So I could learn a lot!
Thanks a lot, great explanation! Wouldn't it be possible to calculate the diffs without abs (column 8), use "1 <= abs(d) <=3" in column 9 and "all(d<0 for d in diffs)" in column 11 and "all(d>0 for d in diffs)" in column 12?
I'm not 100% what you mean by column, but probably :)
@@0xdf I meant line, not column, of course... :D
Clean and great code, but would love a bit of explanation about the thought process about the approach. Cheers
Thanks for the constructive feedback. I'll try to keep that in mind going forward.
this helps me tremendeously. Thank you so much sir, please continue make such great quality videos.
Thanks again 0xdf, awesome as always. Anything else up to your sleeve apart from Advent of Code?
Working on Hackvent and Holiday Hack as usual!
Instead of `target / num == target // num` to check for integer why not `target%num == 0`?
Yeah, that's smarter! Saw that when looking into solutions too.
Yeah anything could be highlighted. Apart from the purism in code best practices, what 0xdf is trying to show is the creativity in his line of his thought to solve these increasingly getting complex coding challenges. Similar to "in range(len(" could be enumerate, on the other hand he is using "map" very wisely. Lets focus on the narrative
@@boogieman97 wasn't trying have a gotch a moment. He is a much better python dev than me and I've learned a lot just watching his AoC videos. Just wanting to learn why that might be a preferable way or if it was just how he likes to do it. Is it more performance, for example.
All good. I'm not offended. They are probably equally performant, and yours is easier to read, so I'd go with that!
I think the order on witch you try the operands can impact how fast the program runs.
Interesting. Why?
@@0xdf my bad, it doesn't😅, i was hoping that the lazy evaluation could do some pruning
As a new programmer, you had me in the first half. In part 2, the refactoring onward is hard for me to comprehend completely. Nevertheless, thank you for taking the time to make this playlist for people like me looking for better solutions after solving or getting stuck
Why don't you participate in Advent of Cyber?
just not really a fan.
Thank you 0xdf. Highly appreciate your channel. I have watched almost all of your content, please continue placing high quality stuff. Your channel excels
Thank you very much!
Great job solving the problems, and explaining your process. :D
Thanks!
Brilliant. Once again. Respect!
Thanks!