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
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
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.
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))
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.
@@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.
@@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.
@@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.
@@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!!
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.
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
AoC is sometimes 80% parsing, that’s why it sucks
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
I'm just glad APL has regex :D
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.
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))
Elegant as usual, but you also need to check for the numbers passed to mul being 1-3 digits.
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.
@@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.
@@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.
@@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.
@@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!!
i just did this one with regexes in my editor and a spreadsheet for the calculations lol
doesn't the code detect false mul if the given input contains something like ")2,4)" ?
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.