Live data from Hacker News

Advent of Code 2023 is nigh

adventofcode.com

171–180 of 319 posts

Re: Advent of Code 2023 is nigh

#171

Earlier quoted context omitted.

Unless the question has been edited recently, it did. There are multiple lines in the second example input that show the overlap: > eightwothree > 4nineeightseven2 > zoneight234 I test my AoC solutions incrementally by printing output, so I found that I was failing to produce the correct list of numbers in a line right away. I suppose if you're taking a faster approach and just trying to extract the first and last nu…

So are you saying that overlapped characters can be used for both numbers? Meaning: - eightwothree -> 823 (answer 83) - 4nineeightseven2 -> 49872 (answer 42) - zoneight234 -> z18234 (answer 14) I interpreted the instructions as saying to take the first match from the left and not count the overlaps. Unfortunately this gives the same answer as the overlap interpretation on the examples given in the problem statement:…

It could have been more clear. The wording from the problem is "the last digit on each line". To me, that pretty clearly implies "the rightmost substring containing a digit", but I guess I can see how someone could question that interpretation.

Re: Advent of Code 2023 is nigh

#173

Earlier quoted context omitted.

What was this edge case you encountered? My code worked...after I finally read the problem closely enough.

For me it was a lack of specific instructions on how to handle overlaps. The edge case that frustrated me for a while was "oneight" at the end of a line. My initial code made it look like this "1ight", when it should have been "18".

When searching for the last number in the line I just reversed the line and scanned through it looking for the reversed strings for the number:

one -> eno

two -> owt

three -> eerht

etc

It makes the entire solution extremely simple, though a little verbose.

Re: Advent of Code 2023 is nigh

#175
post #76

Day one part 2 was relatively rough. Things I learned from it: rust regex crate doesn't support look-ahead, rust onig crate is currently broken in many ways and shouldn't be used (the version in crates.io doesn't compile and the version on GitHub is failing tests and look-ahead isn't working). It was a very frustrating time for me. After 2 hours of troubleshooting the above I used the same approach in python and it t…

It's a Regular Language, in the mathematical sense. All you need is the greedy match anything sequence, I don't know why so many people jumped to non-Regular regex extensions.

Re: Advent of Code 2023 is nigh

#177

I will be doing this advent challenge this year instead: https://adventofchess.com/ Looking forward to read your write-ups!

This looks really cool, but they should make it clearer that you only get one submission per day, and they're not going to check that your answer is valid before submitting.

I submitted this (wrong) answer

1. e3 Na6 2. Bxa6 Nf6 3. Bf1 Ne4 4. d4

but only realised afterwards that it has to be _exactly_ 4 moves, less than 4 moves is not good enough.

Re: Advent of Code 2023 is nigh

#178

Earlier quoted context omitted.

Yes, same. I keep seeing people say this on discord and reddit, but that edge case was shown twice in the example.

It shows an overlap, but it doesn't indicate how one should parse it.

It showed "eightwothree" to be 83. Or is that not what you are talking about?

Re: Advent of Code 2023 is nigh

#179

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.

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.

Re: Advent of Code 2023 is nigh

#180

Without going into spoilers, its interesting that people jumped to regex to solve this. For me that was a fairly non intuitive when I first saw the problem(both parts). What jumped to me is the problem statement indicated a finite number of states and I crafted a solution based on that information. But its really cool to see how we all jump to different implementations.

I also started to write a finite state machine for part 2 but found it too tedious to craft by hand. How did you do it?

Not OP, but I too first thought of a state machine. As soon as I started to write it I realized I was over-solving a day-1 problem. So I switched to brute force

https://pastebin.com/r1jNCSdm

Once I get a line back from that, it's the same problem as part A.

Post reply on HN