Advent of Code 2024 in BQN Day 3!

แชร์
ฝัง

ความคิดเห็น • 17

  • @q_rsqrt5140
    @q_rsqrt5140 2 วันที่ผ่านมา +9

    In this one it really feels like solving a puzzle and not programming - I'm curious is this is just my lack of experience or a nature of string operations with array languages

    • @Ven_de_Thiel
      @Ven_de_Thiel วันที่ผ่านมา

      AoC is sometimes 80% parsing, that’s why it sucks

    • @__Brandon__
      @__Brandon__ วันที่ผ่านมา +1

      I liked this one the best so far. I had spent a while fixing an off by one error on both day 2 and day 4. But parsing out day 3 was straight forward and a first try. Felt more like I was building something inside of debugging. I've been using C to complete them

  • @foresthobo1166
    @foresthobo1166 วันที่ผ่านมา +4

    It's a very pretty solution, that being said my c solution without regex was only about 20 lines for both problems.
    I would have expected the array language solution to be more like like databases with table products and matrix operations.

    • @marcosgrzesiak4518
      @marcosgrzesiak4518 วันที่ผ่านมา +3

      this problem is very sequential. The data is just one long line, so there isn't much to be gained from organizing it in a two dimensional fashion. (Mentioning because I solved it in both an imperative language (Lua) and an array language (Uiua))

  • @MartinClausen
    @MartinClausen วันที่ผ่านมา +1

    Elegant as usual, but you also need to check for the numbers passed to mul being 1-3 digits.

    • @code_report
      @code_report  วันที่ผ่านมา +1

      I don't think so. I read the problem as "you will only encounter 1-3 numbers" not "a 4 digit number is invalid. It wouldn't make sense to have "digits" as corrupt information because it could change a 1 digit or 2 digit number into a 2 or 3 digit number respectively, which would look valid.

    • @MartinClausen
      @MartinClausen วันที่ผ่านมา

      @@code_report I would have to disagree. Valid instructions use 1-3 digit numbers. It specifically says the memory has been corrupted, so you cannot rely on it not to introduce 4 digit numbers.

    • @code_report
      @code_report  วันที่ผ่านมา

      @@MartinClausen It says nothing about 4 digit numbers. It only says there will be 1-3 digit numbers. Regardless of the intent of the problem, my strategy worked. Keep in mind Eric Wastl uses algorithms to generate the random test input. It would take a lot more work to have a sophisticated "corruption" algorithm going from valid "mul(x,y)"s that can introduce digits but never to the x or y in the muls. Odds are it just generates psudeo-random broken muls and joins the valid muls by that stuff. And even if the corruption does mess up the numbers, then we technically aren't recovering the correction sum of products at the end of the day.

    • @MartinClausen
      @MartinClausen วันที่ผ่านมา

      @@code_report 4 digits was just an example. "It does that with instructions like mul(X,Y), where X and Y are each 1-3 digit numbers." -> valid instructions use pairs of 1-3 digit numbers. No where does it say that is the only thing you will encounter, quite the opposite. It says memory has been corrupted, so you cannot assume that you will not see for instance an otherwise valid transaction with for instance a 4 digit number. We have no idea how the input is generated, and even if we did it would hardly in the spirit of the puzzles to exploit that in solving the puzzles. Anyway I appreciate your solutions, it is a fun way to learn BQN.

    • @arisweedler4703
      @arisweedler4703 วันที่ผ่านมา

      @@MartinClausenthe spirit of solving the problem is a great reason to solve it however you think is best 😁 I personally couldn’t let myself solve this any way other than tokenizing and solving. But it’s totally unnecessary to do that!!

  • @PatrickStritch
    @PatrickStritch 2 วันที่ผ่านมา +4

    I'm just glad APL has regex :D

  • @trespaul
    @trespaul 2 วันที่ผ่านมา +6

    i just did this one with regexes in my editor and a spreadsheet for the calculations lol

  • @しめい-l4m
    @しめい-l4m วันที่ผ่านมา +2

    doesn't the code detect false mul if the given input contains something like ")2,4)" ?

    • @code_report
      @code_report  วันที่ผ่านมา +1

      Yea, I was pretty sure there were one or two corner cases that my solution would fail for (this one definitely would) - but I figured there was a chance they wouldn't exist for the input.