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
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?😢
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.
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
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
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!
@@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!
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.
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!
using 9 separate min heaps for each empty block size is definitely a good way to go! Very insightful, thanks Neil!
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
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?😢
Big thank you for these videos!
The "I got points!! :D :D :D" brings me joy
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.
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
Congrats on day 10 leaderboard too king
Again just barely haha, but thanks!
@@nthistlethwaite mfw im trying to solve day 12 part 2 before ur insane video drops
@@MattDog_222 the video file is processing right now 8)
Congrats on making it back to the leaderboard!
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
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!
@@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!
14:37 this is so relatable haha
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
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.
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!
You look like young Kevin Spacey. Are you his son?
🤔