Advent of Code 2024 Day 9 - Back on Leaderboard!

Поделиться
HTML-код
  • Опубликовано: 23 янв 2025

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

  • @thedoodler882
    @thedoodler882 Месяц назад

    using 9 separate min heaps for each empty block size is definitely a good way to go! Very insightful, thanks Neil!

  • @LogicalErrors
    @LogicalErrors Месяц назад +1

    Big thank you for these videos!

  • @schrummy14
    @schrummy14 Месяц назад +3

    Great job making onto the leaderboard.
    Both of my solutions used left and right pointers.
    Definitely needed pypy for part 2 for my solution.
    Python -> 4.62 seconds
    pypy -> 0.15 seconds
    c++ -> 0.04 seconds

    • @luckychouhan3393
      @luckychouhan3393 Месяц назад

      How did you solved this much faster in c++? I wrote three function for all three steps of part 1 but still not getting right answer :( Would you share your code please?😢

  • @JamesSorenson
    @JamesSorenson Месяц назад

    Congrats on making it back to the leaderboard!

  • @TigerWalts
    @TigerWalts Месяц назад +1

    In part 1 I used a deque in a generator that yielded file ids from the head, when it hit a free spot it dropped free spots from the tail until it hit a file id to yield and then it flipped back to working the head.
    Using 2 index cursors on a list would probably have done the job though.

  • @MattDog_222
    @MattDog_222 Месяц назад +1

    Congrats on day 10 leaderboard too king

    • @nthistlethwaite
      @nthistlethwaite  Месяц назад

      Again just barely haha, but thanks!

    • @MattDog_222
      @MattDog_222 Месяц назад

      @@nthistlethwaite mfw im trying to solve day 12 part 2 before ur insane video drops

    • @nthistlethwaite
      @nthistlethwaite  Месяц назад

      @@MattDog_222 the video file is processing right now 8)

  • @TheXztream
    @TheXztream Месяц назад +1

    My part 1 solution was based on keeping track of the index of the first empty space and the index of the last digit, and then keep looping until the space index was greater than the digit index, at each iteration the search started from the last index values, which gives me time complexity O(length of input). Finds solution in around 60 ms.
    For part 2 I kept track of two lists of intervals and looked for the first space interval that could fit the file and updated the interval, if the interval after the update were of length 0 i removed it (reducing the number of checks in future iterations). Part 1 & 2 takes around 350ms to calculate

  • @baptistemarchand
    @baptistemarchand Месяц назад

    The "I got points!! :D :D :D" brings me joy

  • @n0ne0ne
    @n0ne0ne Месяц назад +1

    14:37 this is so relatable haha

  • @Leanyoshi
    @Leanyoshi Месяц назад +2

    is there any reason why you dont just run `pip freeze > requirements.txt && pypy -m pip install -r requirements.txt`? That way you have all your dependencies in python and pypy and dont need to comment out stuff

    • @nthistlethwaite
      @nthistlethwaite  Месяц назад

      I definitely have a lot of dependencies that just don't work being installed in pypy for whatever reason - I think z3 bindings and perhaps numpy come to mind? But I actually don't use these all that often, so I should probably just do this for everything else, yeah. I didn't realize that pyperclip was pypy-compatible until just now, so at the very least I can remove my silly try-catch for that. Thanks for the tip!

    • @Leanyoshi
      @Leanyoshi Месяц назад

      @@nthistlethwaite ah, maybe upgrade to pypy 3.10 then. I just tested my z3 solution from last years 24 with pypy and the latest version works with the z3-solver package, so one more dependency to not worry about!

  • @Kyle-nt7nl
    @Kyle-nt7nl Месяц назад +1

    I think the guy that placed first in 27 seconds is totally full of it, not to be a hater I just don’t believe it at all

    • @timfennis91
      @timfennis91 Месяц назад +2

      Yeah there is just absolutely no way. Even if you consider this puzzle a very easy problem you have to figure out how the input is parsed, what's actually being asked and how the final checksum is calculated. There is no way you can figure that out and type all that code in 27 seconds.

    • @nthistlethwaite
      @nthistlethwaite  Месяц назад

      Yeah I mean I'm definitely somewhat suspicious for all the reasons @timfennis91 mentions, but there is some level of "it's hard to imagine someone significantly better than you" that makes me not want to jump to conclusions too quickly. If I can skim and understand the problem statement in 60 seconds, how confident can I be that nobody can do it in 15 seconds?
      I also think there's not much point in me stressing about or getting mad at someone else maybe cheating, since there's not much I can do about it personally anyways. Better for me to focus on myself and get the best times that I can!

  • @buireolbg
    @buireolbg Месяц назад

    You look like young Kevin Spacey. Are you his son?