Solving for the Largest Summation of Numbers - Advent of Code 2022 Day 01

Поделиться
HTML-код
  • Опубликовано: 30 ноя 2022
  • Attempting the 24 days of advent code this year - come along for the journey and learn some code! We'll be using Python for the initial algorithms, and if I have time I'll be redoing them in Rust (on my github profile, link below)
    Get caught up on those socials to know when the next video drops:
    / discord (We have a Discord server now!)
    / retrofluxtweets (Every new video is posted here!)
    / retroflux_twitch (I stream sometimes too)
    / retroflux (We have a subreddit now!)
    / patreoflux (Only give what you can spare please!)

Комментарии • 9

  • @user-es8ss4ur9p
    @user-es8ss4ur9p Год назад +2

    He’s back!! 🥳🥳

  • @silicalnz
    @silicalnz Год назад +1

    Nice. Good luck. The real challenge is doing it everyday and not getting busy with other things. haha

  • @fireflysparkava
    @fireflysparkava Год назад

    Haha, I'll be doing it alongside you! Thanks for posting about it by the way, I'd never heard of it before you posted last year and then you reminded me again that it existed this year. Interested to see what solutions you come up with :)

  • @1Andypro
    @1Andypro Год назад +4

    Thanks for tackling the Advent of Code this year. For future problems, please up your browser and editor font sizes by a lot for the video if possible!

    • @Retroflux
      @Retroflux  Год назад +1

      Will do! I didn't get the zoom in for the day 2, but will try and get it set up for day 3 onwards. :)

  • @ChampionJan
    @ChampionJan Год назад +4

    Nice solution! As a final year Com Sci student, I have never heard of the Advent of Code lol. I have finals starting on Monday so I don't think I will have time to solve it myself but at least I can give thoughts as to how I would solve the problem when I watch your videos.
    For the second part of the question, alternatively I would have an array initialized with 3 zeroes (basically [0,0,0]) and everytime we get an elf's total, we would add it to the array, sort the array and then I would slice the list for the first three largest elements (lst[:3]). Then at the end, just sum the list. I don't know if it's a more efficient solution but I think it's cool that if they asked for the n largest totals then all we would have to do is replace lst[:3] with lst[:n] (and replace [0,0,0] with lst = [0] * n)

    • @Retroflux
      @Retroflux  Год назад +2

      That's an interesting take, though I'd be concerned about using in a progamming language like Python that is already extremely (comparatively speaking) ineffienct. You'd probably also have a huge memory overhead from all of the swaps, creations, and slices, but the tradeoff would be a very elegant solution.
      What you COULD do if you want a general solution is:
      i) take in the length of the output list (n) as a command line argument
      ii) modify the insertion algorithm into a short-circuit algorithm that creates a pre-index slice + insert value + post-index slice to return (ex. [x-i:] + newVal + [:x]), and determine which components to slice based off that short-circuit (go through list until you find the insertion point, take note, and break out and handle the insertion).
      Some languages will handle that kind of list modification better than others at the cost of memory overhead, but something low-level like C might actually be the best option because of the granular modifications you could make.
      Good luck on exams :)

    • @ChampionJan
      @ChampionJan Год назад

      @@Retroflux Oooooh those are very smart ideas. I really like the suggestions because the memory overhead would be insane fr. I can't wait to see the next video to spitball more crazy ideas. Oh and thanks for the well wishes for exams, I'll need em lol

  • @patrickhogg6948
    @patrickhogg6948 Год назад

    I wonder if you'd want to set up a private leaderboard for you and your viewers to compare progress. You'd probably want to use the Stars ordering (which ranks based on stars collected, breaking ties by the time of the most recent star collected) rather than the others as people won't all be starting at the same time.