Neil Thistlethwaite
Neil Thistlethwaite
  • Видео 72
  • Просмотров 118 966
Advent of Code 2024 Day 19
Advent of Code 2024, Day 19. I finished 124th and 166th. This is the second day that I solved part 2 first, although this time I at least didn't have a wrong submission for it.
I missed AOC yesterday (day 18) because I was at an event that ran late, but I will upsolve it at some point!
Просмотров: 1 077

Видео

Advent of Code 2024 Day 17 Solve
Просмотров 3,1 тыс.4 часа назад
Advent of Code 2024, Day 17. Tough day, but a fun one! I ended up using a constraint solver (Z3) for part 2 today, and I'm definitely not the best with it. There also was a much simpler approach towards it that I missed completely. 0:00 - Intro 0:04 - Part 1 7:36 - Part 2 1:04:45 - Explanation
Advent of Code 2024 Day 16
Просмотров 2,7 тыс.7 часов назад
Advent of Code 2024, Day 16. I finished 190th and 86th today, so I did make it on the part 2 leaderboard at least! This was a relatively standard "shortest paths on a grid [with a twist]" problem, of which a few have definitely come up in previous years of AOC. Still a fun problem. I did write a couple bugs - see if you can spot them before I do! One of them didn't actually end up causing probl...
Advent of Code 2024 Day 15 - 2nd Place!
Просмотров 3,8 тыс.9 часов назад
Advent of Code 2024, Day 15. I got 35th on part 1 and 2nd on part 2! My highest finish of the year! Sadly, I was only 3 seconds away from first place, and there were definitely a few places where I could have been 3 seconds faster (in particular I started a few seconds late because I got home late today). But honestly I'm thrilled just to get 2nd, and to get a high finish on both parts, somethi...
Advent of Code 2024 Day 14 - 12th gold star!
Просмотров 3,3 тыс.12 часов назад
Advent of Code 2024, Day 14. I got 159th on part 1 and 12th on part 2! Do LLMs know what Christmas trees look like? I wonder. I'm sure it wasn't intentional, but part 2 definitely felt like an "anti-LLM" question today. Today's puzzle was cute, definitely one of the more unique parts of Advent of Code is having underspecified goals like today's - on the one hand it's pretty neat, on the other n...
Advent of Code 2024 Day 13
Просмотров 2,2 тыс.14 часов назад
Advent of Code 2024, Day 13. Finished 191th and 136th - another pair of high (but not top 100) finishes. I actually got to my computer just a minute or two before AOC today so I was rushing to get everything set up, missing my pre-AOC typing practice seems like it cost me at least a bit in making typos. I'm trying a new webcam and microphone setup today, let me know how it compares to previous ...
Advent of Code 2024 Day 12 - 16th Gold Star!
Просмотров 3,4 тыс.16 часов назад
Advent of Code 2024, Day 12. I finished 205th for the first part and 16th for the second! Fun problem - I was pretty surprised how big my improvement in ranks was, but I'm guessing a lot of it is because LLMs just can't solve the second part (and maybe there's more of them on the leaderboard than I previously thought...). 0:00 - Intro 0:04 - Part 1 4:00 - Part 2 6:50 - Explanation
Advent of Code 2024 Day 11
Просмотров 2,6 тыс.19 часов назад
Advent of Code 2024, Day 11. Fun problem! Feels very "classic" for Advent of Code, which I enjoyed. Missed leaderboard by a good bit on part 1, but I was pretty close on part 2! I would've barely made it if I hadn't had a wrong submission on part 1 because I misread what it was asking for... 0:00 - Intro 0:05 - Part 1 3:12 - Part 2 6:51 - Explanation
Advent of Code 2024 Day 10
Просмотров 2,4 тыс.21 час назад
Advent of Code 2024, Day 10. I finished 200th and 94th - another day of barely making leaderboard, which is certainly better than not making leaderboard. Notably I had a super fast split for part 2 today - 18 seconds! 0:00 - Intro 0:05 - Part 1 3:54 - Part 2 4:13 - Explanation
Advent of Code 2024 Day 9 - Back on Leaderboard!
Просмотров 2,7 тыс.День назад
Advent of Code 2024, Day 9. I finished 118th for part 1 and 84th for part 2 - finally back in the top 100 for a day! Hopefully this trend continues, but we'll see. I think the biggest thing was just that I didn't write any (major) bugs today, which, unsurprisingly, helps a lot when it comes to finishing well. 0:00 - Intro 0:04 - Part 1 6:17 - Part 2 13:06 - I yap
Advent of Code 2024 Day 8: Linear Algebra?
Просмотров 3 тыс.День назад
Advent of Code 2024, Day 8. Another day, another bug(s)! Even without hiccups on my side though, I definitely wrote a much slower to implement approach for the first part. It did make part 2 really fast though, since all I had to do was comment out some code, which was nice.
Advent of Code 2024 Day 7
Просмотров 2,6 тыс.День назад
Advent of Code 2024, Day 7. Another day of "fast, but not fast enough", I got around rank 240 for both parts. This is mostly on me for writing bugs though, see if you can spot my bugs before I do in realtime! :P 0:00 - Intro 0:02 - Part 1 3:41 - Part 2 5:54 - Explanation
Advent of Code 2024 Day 6
Просмотров 3,9 тыс.День назад
Advent of Code 2024, Day 6. I finished 121th and 227th, so still no leaderboard (the dry streak continues!), although I definitely feel a lot better about these placements than the 2000~3000th from the last couple days... 0:00 - Intro 0:04 - Part 1 3:08 - Part 2 12:08 - Explanation
Advent of Code 2024 Day 5
Просмотров 2,9 тыс.День назад
Advent of Code 2024, Day 5. Another rough day for me on part 2 :(
Advent of Code 2024 Day 4
Просмотров 2,7 тыс.14 дней назад
Advent of Code 2024, Day 4. If you couldn't tell by the length of the video, I did not do well on this day. For whatever reason I got really confused on part 2 and consistently misinterpreted what the problem was asking for :(
Advent of Code 2024 Day 3: Regex
Просмотров 5 тыс.14 дней назад
Advent of Code 2024 Day 3: Regex
Advent of Code 2024 Day 2
Просмотров 4 тыс.14 дней назад
Advent of Code 2024 Day 2
Advent of Code 2024 Day 1 - Top 20 Finish!
Просмотров 9 тыс.14 дней назад
Advent of Code 2024 Day 1 - Top 20 Finish!
I finished 4th overall in Advent of Code 2023!
Просмотров 4,8 тыс.11 месяцев назад
I finished 4th overall in Advent of Code 2023!
Advent of Code 2023 Day 24: Choking a 4th place finish on part 1
Просмотров 1,3 тыс.11 месяцев назад
Advent of Code 2023 Day 24: Choking a 4th place finish on part 1
Advent of Code 2023 Day 22 - Top 5!
Просмотров 90411 месяцев назад
Advent of Code 2023 Day 22 - Top 5!
Advent of Code 2023 Day 23 Solve
Просмотров 1,5 тыс.11 месяцев назад
Advent of Code 2023 Day 23 Solve
Advent of Code 2023 Day 18 Solve
Просмотров 50711 месяцев назад
Advent of Code 2023 Day 18 Solve
Advent of Code 2023 Day 17 Solve
Просмотров 32211 месяцев назад
Advent of Code 2023 Day 17 Solve
Advent of Code 2023 Day 16 Solve
Просмотров 450Год назад
Advent of Code 2023 Day 16 Solve
Advent of Code 2023 Day 15 Solve
Просмотров 293Год назад
Advent of Code 2023 Day 15 Solve
Advent of Code 2023 Day 14 Solve
Просмотров 362Год назад
Advent of Code 2023 Day 14 Solve
Advent of Code 2023 Day 13 - #17 and #5!
Просмотров 348Год назад
Advent of Code 2023 Day 13 - #17 and #5!
Advent of Code 2023 Day 12 Solve
Просмотров 874Год назад
Advent of Code 2023 Day 12 Solve
Advent of Code 2023 Day 11 in the airport!
Просмотров 782Год назад
Advent of Code 2023 Day 11 in the airport!

Комментарии

  • @harisimer
    @harisimer 32 минуты назад

    i never understood why its called dynamic programming

  • @Tresorthas
    @Tresorthas 3 часа назад

    What was the problem with `functools.cache`?

  • @dickeyy
    @dickeyy 4 часа назад

    my solution for today was insanely similar to yours, im proud of myself now

  • @Erwipro
    @Erwipro 7 часов назад

    My bug was that I thought you couldn't reuse towels. The input was constructed in a way that this rendered a correct answer for part 1, but obviously not for part 2.

  • @n0ne0ne
    @n0ne0ne 9 часов назад

    That was an unfortunate bug. You would've surely gotten top 100 for p2

  • @Bundas102
    @Bundas102 10 часов назад

    Interesting bug there. I was too lazy for part1, so I just used regex matching. "^(" + patterns.join('|') + ")*$" does the trick. Ocf I had to implement the counting for part2 anyways. First I just did it recursively, then quickly realized, that it won't finish, so I threw my caching wrapper on it.

    • @n0ne0ne
      @n0ne0ne 8 часов назад

      can you share your code for p1?

    • @Bundas102
      @Bundas102 8 часов назад

      @@n0ne0ne I did it in JavaScript. inp is an array of the input lines: function solve1(inp){ let c = 0; const patterns = inp.shift().split(', ') inp.shift() const regex = new RegExp("^("+patterns.join('|')+")*$") for (const r of inp) { if(r.match(regex)) c++ } return c }

    • @n0ne0ne
      @n0ne0ne 7 часов назад

      @@Bundas102 Thanks

  • @yajusgakhar6969
    @yajusgakhar6969 11 часов назад

    When will the Tower of Hanoi stop haunting meee

  • @acquite
    @acquite 11 часов назад

    omg youre back!!!!!!!!!!

  • @thedoodler882
    @thedoodler882 14 часов назад

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

  • @nasccped
    @nasccped 15 часов назад

    Dude solved in 40 secs what I couldn't solve in two days wth 💀

  • @augustdahlkvist3998
    @augustdahlkvist3998 19 часов назад

    You know the problem is cooked when this guy is taking an hour to solve it.

    • @tylermmalone
      @tylermmalone 18 часов назад

      @@augustdahlkvist3998 fr lol

  • @stephenmorse8207
    @stephenmorse8207 20 часов назад

    No day 18 video? It was an easy one!

  • @nicklase0000
    @nicklase0000 20 часов назад

    I'm not sure the code will look correct, but this was my solution for the second part: def test(a, b, c, prg, k): idx = k while idx < len(prg): b = a % 8 b = b ^ 1 c = int(a / (2**b)) a = int(a / 8) b = b ^ c b = b ^ 6 if b % 8 == prg[idx]: idx += 1 else: return idx return idx prg = [2, 4, 1, 1, 7, 5, 0, 3, 4, 3, 1, 6, 5, 5, 3, 0] def solve(idx, a): if idx < 0: print("solution", a) return for aa in range(0, 8): aaa = 8 * a + aa res = test(aaa, 0, 0, prg, idx) if res == 16: print(idx, res) solve(idx - 1, aaa) solve(15, 0)

  • @gerardomiranda2284
    @gerardomiranda2284 День назад

    I used brute force... But, the trick for me was reducing the range. basically I noticed that the last elements were the last to change, so I just narrowed the range based on the last elements of the output and comparing them with the last elements of program. That way the brute force took like 5 minutes

  • @DoctorDuckload
    @DoctorDuckload День назад

    Amazing. I actually coded your very last idea. No way I could have reverse engineered the thing without any hints. But the recursive DFS with backtracking is simple to code and it works very fast once you figure it out.

  • @noomade
    @noomade День назад

    you can sort the update by using a custom comparator where instead of a > b you just check if (a,b) in rules. This is because if a,b are in the rules then a must be > b. update.sort(key=functools.cmp_to_key(lambda a,b: -1 if (a,b) in rules else 1))

  • @Tresorthas
    @Tresorthas День назад

    What an insanely inane problem. Every year has at least one, usually around day 20-23, but this year we seem to get it early. Let's hope there will only be more sensible ones going forward.

  • @1vader
    @1vader День назад

    You can actually just do modulus, bit shift, and division on bit vecs in z3. I mostly just re-used my code from part 1, replaced "a" with a z3 BitVec variable, and let that build up the right conditions. Had to replace // with / (which is always floor division on a BitVec) and 2**x with 1 << x but that's more or less it (besides adding constraints to the solver on output and the loop instructions ofc). Though for me, the initial solution it found was not the lowest (my input had two different possible solutions). z3 actually even has Optimize() instead of Solver() and then you can minimize(a) to make sure you find the lowest but that was a bit slow for me (though it seems to have worked for other people). I just let it find all solutions (by continuously adding "a != solution" as a constraint) and then chose the lowest. Also, z3 technically is an SMT (satisfiability modulo theories) solver, not (just) a SAT solver. That's why it can also solve equations with proper integers without a fixed bit size and stuff like that. Actually, it can even find functions that satisfy given constraints.

  • @tomwatson7114
    @tomwatson7114 2 дня назад

    Mine was a pretty awful bruteforce solution that somehow worked, but I recognised that my reversed outputs would "roughly" increment as my A register got larger, and so using a binary search to find the approximate region of the correct answer and then iterating in chunks of descending size as I got closer to the input program got me the answer in sub 4 seconds (Python). Disgusting, but it worked :D

  • @IulianYT
    @IulianYT 2 дня назад

    I am not a speed coder, but I didn't even bother to write code to parse input, I just manually introduced the variables straight away

  • @mathiaskern7031
    @mathiaskern7031 2 дня назад

    Try A=0...7 for your program and see which values output the last number of the program. Try those (recursively). Shift them 3 bits to the left, and then combine them via OR once more with values 0 to 7, and see which produce the second last number of the program, and so on. You will encounter some dead ends and then the recursion backtracks, but in the end you will have a number (at least one) of candidates for A that produce the desired program. Pick the smallest one. The code is not very long as it uses the run/execute method from part 1.

  • @bikkel77
    @bikkel77 2 дня назад

    Was a nice journey this one (I made a walkthrough video about my solution). Had a couple of insights after decompiling the program which turned all operations into bit operations ('left shift', 'right shift', 'and' and 'xor', modulo 8 is just 'and' 7 and division by '2 to the power i' is just 'right shift i'): - The input value has to be 3*instructions.length in terms of bits (so 48 bits long) - The program runs basically a loop until the output value (new value of 'a' after one loop) is zero - Each step at most uses the 10 least significant bits of value a, however to yield a zero output it's possible to only try 8 different values. - The outputValue of each loop has to match up with the required inputValue of each loop to yield the expected output string. So a basic DFS or BFS can be done by starting from the end of the instruction list and working your way backwards to the start, each time left shifting your value with 3 bits. For each instruction you only have to do at most 8 iterations to match 3 bits of input. Doing this the code runs in less than 50 ms.

  • @God-i2
    @God-i2 2 дня назад

    Abu Bakar Al Bagdadi Is Dead

    • @cursed_nerd
      @cursed_nerd 2 дня назад

      bro you lagging irl

    • @God-i2
      @God-i2 2 дня назад

      @cursed_nerd He died like a dog

  • @Bundas102
    @Bundas102 2 дня назад

    I wrote the inverse of the instructions. One instruction in the loop needed an operand that wasn't yet resolved, but only 0..7 give different results, so i just did a dfs on that. I got 62 possible answers and the minimum is the right answer. Too bad it took me 2 hours do it :D JS screwed me a bit. I don't usually use it, basically only for AoC, so I didn't know xor casts to 32 bit integers. Luckily I noticed it quickly enough. Btw the divisions are actually right shifts by the combo op.

  • @oofmatoes
    @oofmatoes 2 дня назад

    My bruteforce from 7 hours ago is still running

    • @tylermmalone
      @tylermmalone 2 дня назад

      lol

    • @LogicalErrors
      @LogicalErrors 2 дня назад

      What speed are you up to? After some optimisation mine was doing more than a billion per hour, without further info that looked fast, so also kept it running. Then took a closer look at the numbers. The 3-bit, modulo 8, situation seems to indicate that the amount of numbers in the output increase for n in 8^n. Given the amount of numbers in my input program a quick calculation later it seems that would take at least 34 years for a full brute force at my speed 😅.

    • @NStripleseven
      @NStripleseven День назад

      DW, you’ll get there eventually. Final answer is only like 2^45

    • @n0ne0ne
      @n0ne0ne 19 часов назад

      still running?

  • @MalicePandrodor
    @MalicePandrodor 2 дня назад

    Interesting approach. I just printed first ~10k outputs and tried to spot the pattern. If you look at the first number in all outputs you can see it creates a sequence that repeats every 1024 (I assume this is the case for all test cases). The second number in all outputs appears at 8th position (for reg A = 8) and follows the same sequence but every number is repeated 8 times (you need to skip the first element for the first occurrence in the sequence, not sure why :D). The same for 3rd number in the output. Starts from the 8*8 (reg A = 64) and follows the sequence when every number is repeated 64 times. And so on. To find the answer you have to create a number in form: a15 * 8^15 + a14 * 8^14 + ... + a2 * 8^2 + a1 * 8^1 + a0 * 8^0 and put it as a input for the program (testing even very high number is very fast). You have to find the a15 that gives expected last number, then to find a14 that gives the second last number and so on, up to the a0.

    • @bikkel77
      @bikkel77 2 дня назад

      If you look at the decompiled program, this can be explained by the fact that at most 10 bits are used of the value of A. It is at most right shifted 7 times and then the three least significant bits are used in an xor.

    • @NStripleseven
      @NStripleseven День назад

      Did everyone get the same input for this one?

    • @MalicePandrodor
      @MalicePandrodor День назад

      @@NStripleseven I don't think so

  • @Bhuyakasha
    @Bhuyakasha 2 дня назад

    For the 2nd part there are some tricky cases if you go for the wrong strategy. I also initially went for a strategy which keeps track of only the fronts of the pile of boxes instead of all of them, but it's very annoying to handle cases with a '.' between two boxes in your pile.

  • @artemistrubacheev7704
    @artemistrubacheev7704 2 дня назад

    I've tried using z3 too, but I am so bad at it I ended up doing bitwise brute force as everyone else :D

  • @WayoshiM
    @WayoshiM 2 дня назад

    I saw the every three contiguous bits of A maps to each output fairly early on, just didn't expect that to be brute forceable (laughably so - the sample space really grows small).

  • @FidelisAkilan-nu6vm
    @FidelisAkilan-nu6vm 2 дня назад

    Was stuck in part 2 way too long, Thanks for the explanation

  • @augustdahlkvist3998
    @augustdahlkvist3998 2 дня назад

    How did your program work when you didn't clear the _from correctly? In the case where we find a new strictly lower distance it should be cleared, no? Edit: saw the end bit but still not sure. Why is it true that the first time you visit a node is the best way to get there?

    • @MattDog_222
      @MattDog_222 2 дня назад

      i roughly believe its because you're staying on the initial shortest path, but because rotations are so expensive, you'll never discover a 'shortcut' later on as that shortcut would have introduced new rotations

  • @baptistemarchand
    @baptistemarchand 2 дня назад

    Watching this while drinking a big glass of LLM tears. Yummy. I hope this trend continues!

    • @VaughanMcAlley
      @VaughanMcAlley 2 дня назад

      I’ll watch this when I finish Day 15 (probably in 3 months, haha), but it’s great to see the humans prevailing.

  • @harisimer
    @harisimer 2 дня назад

    interesting, i had the same answers as you. I actually thought the difference between bfs and djikstras is exactly that the first time you reach a new node it doesnt have to be the cheapest way to reach it.

  • @8ABC8
    @8ABC8 3 дня назад

    Amazing stuff. Congrats.

  • @mairex3803
    @mairex3803 3 дня назад

    Sick work man. That part two was tough imo

  • @nikhilraj1845
    @nikhilraj1845 3 дня назад

    Bro whats the final answer which we have to submit

    • @alexjando4880
      @alexjando4880 3 дня назад

      U need to calculate it yourself buddy 😂. This isn't just some copy paste Type thing.

  • @IanBurgan
    @IanBurgan 3 дня назад

    Clearing the set in `from_` is actually important! My input breaks without it. The case in which it breaks is at an intersection. First, the node at the middle of the intersection is visited while going up with some distance X. While visiting the node, the same node but facing to the right is added to `dists` with a distance of X + 1000. Later on, the same intersection is approached from the left. The middle node while facing to the right can now be visited for less than X + 1000.

  • @harshnj
    @harshnj 3 дня назад

    Great! For the first time I made <1k rank 322 for part1 but got stuck miserably for part2 😅

  • @mallesbixie
    @mallesbixie 3 дня назад

    Great work! Amazing how your head keeps track of it all, and manages to explain what you're doing. I spent all day debugging to no avail, but made great visuals!

  • @bikkel77
    @bikkel77 3 дня назад

    Great respect for you sir! Even explaining your thoughts while you’re at it at this speed is incredible.

  • @yassine-sa
    @yassine-sa 3 дня назад

    4:08 you could have just put a box in the empty space and put the robot in the box it's next to. Tricky but not too tricky

  • @TheFrogfather1
    @TheFrogfather1 3 дня назад

    Sadly completely stuck on part 2 after many hours. My solution solves the small test puzzle but not the larger one. I’ll maybe have another look later.

  • @jacobgsutton
    @jacobgsutton 3 дня назад

    I was so happy to see you in second last night.

  • @paulc9239
    @paulc9239 3 дня назад

    Congratulation !!! Pretty funny to see you arrive late today and finish a the 2nd place for the part 2 ahaha

  • @MichelKraemer
    @MichelKraemer 4 дня назад

    Congratulations! 🎉

  • @God-i2
    @God-i2 4 дня назад

    Hey Senior AI engineers! Looks like your LLMs not that smart ha! BURN IN THE DEPTHS OF THE FLAMES OF HADES!!! HA HA HA HA HA!!!

  • @thijsyo
    @thijsyo 4 дня назад

    That was cheesy 🍕🧀 but very quick thinking!! I just printed after every second (with some delay to get down to 60fps) and just quickly keyboard interrupted when I saw the tree. Definitely not as fast but still very satisfying😄

  • @Sam_Forette
    @Sam_Forette 4 дня назад

    congrats man. love your vids

  • @cursed_nerd
    @cursed_nerd 4 дня назад

    sick

  • @IulianYT
    @IulianYT 4 дня назад

    27:08 - afaik sets are not ordered. But, I was using sets for each step (I can't think of a scenario when one coordinate is added at one step, then tried to be added after some steps. So, you have the robot, then you have a set of boxes which need to move, which are adjacent to the robot, then set of boxes which need to move and are adjacent to first set of boxes, then set of boxes adjacent to second set and so on. And then added these sets to the list, so I could have order. It doesn't matter in which order you "process" boxes inside a "set", if they are "same distance" from the robot, but it makes sense to process sets one after another.