top | item 38488409

(no title)

aaaronic | 2 years ago

I think the edge cases were entirely unclear in day 1, part 2. I had to redo it in a "dumb"/brute-force way to avoid using fancy regex tricks I don't know.

It's quite clear the small sample data was chosen intentionally to not cover them.

discuss

order

WJW|2 years ago

The problem statement was super clear though. "Find the first occurrence of any one of these strings in a longer string" doesn't require any fancy regex tricks, just a for loop and knowledge about `isPrefixOf` or `startsWith` or whatever the equivalent function is called in your language of choice.

"Find the last occurrence of any one of these strings in a longer string" is just the first problem again but with all the strings reversed.

cjbprime|2 years ago

Disagree that it's clear. If the text is "oneight", there is a legitimate philosophical question about whether the string contains two numbers. I feel like most people would say no, because the only way to answer yes is by re-using letters between different words, and that's not how language works.

masklinn|2 years ago

> knowledge about `isPrefixOf` or `startsWith` or whatever the equivalent function is called in your language of choice.

There's no guarantee the digits are the first or last, so it's more `find` and `rfind`, unless you try every subslice of the line by hand.

Although thinking about it assuming the lines are not too long I guess that also works.

adbachman|2 years ago

that's interesting.

my example data did include the edge case that caught me out in part two, but didn't include it in a way that broke my first pass at a solution.

funny piece is it didn't click until i submitted a wrong answer, read my code for a few minutes, added a bunch of logging, and then saw the trick. i looked back at the given example and it was right there the whole time, just not called out explicitly.

timeon|2 years ago

> It's quite clear the small sample data was chosen intentionally to not cover them.

I wonder if it is because of ChatGPT and friends.

masklinn|2 years ago

> It's quite clear the small sample data was chosen intentionally to not cover them.

That is very common in AOC, the edge cases are often not called out.

Although the results vary a lot, sometimes the edge cases matter, sometimes they only matter for some data sets (so you can have a solve for your dataset but it fails for others), and sometimes the edge cases don’t matter at all, so you might spend a while unnecessarily considering and handling them all.

The edge cases are fine tho, it’s a normal thing which happens. The not fun ones are when ordering comes into play to resolve ambiguities and is not called out, it’s quite rare but when it happens it’s infuriating because it’s very hard to debug as you don’t really have a debugging basis.