Live data from Hacker News

Advent of Code 2023 is nigh

adventofcode.com

301–310 of 319 posts

Re: Advent of Code 2023 is nigh

#301

Earlier quoted context omitted.

You need to put a time limit on your regex execution no matter what, if you're parsing untrusted input.

Not necessarily. But it's complicated. See: https://docs.rs/regex/latest/regex/#untrusted-input One of the key advantages of a regex engine based on finite automata is that it lets you make guarantees about the runtime performance of a search.

Okay, let me amend my comment. If you have a degree in CS, you're absolutely sure that you've understood all the caveats of the libraries you're using, and you limit your inputs so that the expected running time is under your target execution time, then you can avoid putting a timeout on your regex executions. In any other case, add a timeout.

Re: Advent of Code 2023 is nigh

#302

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.

> 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.

Re: Advent of Code 2023 is nigh

#303
post #124

Earlier quoted context omitted.

I'd actually welcome it if the leaderboard was abolished. I never really played for placement, but something about the fact that the board was full of people who routinely solve every problem in about the same time it takes me to even READ the description was a bit demotivating. I always felt this racing aspect to be somewhat at odds with the idea that this is a challenge that you can complete in your own time, maybe…

To add to this, AoC release its puzzles at midnight ET, so the west coast folks who are still up at 9pm PT will almost always complete the puzzles before someone on the east coast who actually sleeps a regular schedule.

It’s also the middle if the day in east Asia, and in Europe it require being ready to rumble at 5-6AM.

But that’s just how it is. Some folks are really invested and update their lives based on AoC drops, I’d assume most neither care nor even try. If you don’t look at the leaderboards there’s nothing telling you there are leaderboards.

Re: Advent of Code 2023 is nigh

#304

Earlier quoted context omitted.

I can recommend raku. Always fun.

The only problem with these kinds of languages is finding the place where the experts publish their solutions, if they do. I'd love to see what an expert can do and what I can learn from them.

/r/adventofcode has an impressive collection of weirdoes solving in all sorts of random nonsense every year.

Re: Advent of Code 2023 is nigh

#305
post #165

I think I’d like to try this year’s in a language I haven’t touched before. What languages should I consider if I want something paradigmatically different from Go, Python, etc?

If you haven't tried Rust: Someone put together a very nice template in Rust that automatically downloads tests, solutions, creates a scaffold for the binaries, etc and submits solutions through CLI. I used this template last year to learn Rust and it got me "up and running" quickly and easily. https://github.com/fspoettel/advent-of-code-rust

Creating your own can be fun tho. My version uses a procedural macro (was a good excuse to finally implement one) to automatically fetch the data set and cache it, and provide a few common helpers.

Re: Advent of Code 2023 is nigh

#306

I've never done AoC before. It seems like the success criteria is primarily about getting the correct answer, and secondarily about submitting a solution as quickly as possible if you want to be on the leaderboard. Is that right? Is there any centralized place for seeing other people's solutions? I'd like to be able to learn from how others approach the problem, and what more elegant or performant solutions exist tha…

You can check the subreddit https://www.reddit.com/r/adventofcode/ Usually each day there is a mega thread with people sharing their solutions

A really cool thing about the subreddit is they archive all the megathreads so if you want to do the old advents you can still find some discussion / hints / …

Sadly not the various help or complaint threads, or the mad lads playing up the ante, but…

Re: Advent of Code 2023 is nigh

#307

As others have said, part 2 of today's was really difficult. I finally solved it using Python regex `overlapped=true`, but it was very tricky. The irritation of having all of the test cases passing, but it failing for my challenge input! I hope it doesn't scare off newcomers, but I already know a few who have given up on part 2.

I heard the question was difficult before solving it, and then I was surprised when I didn't hit any speed bumps. The overlapping case didn't even occur to me. It turns out I stumbled upon a simple solution: use two regexes. One to match the first digit, and one to match the last. Then the overlapping is a total non-issue.

Yeah, that's what I did for part 2 and there were no issues. I did try to solve it with a single regex at first, but for some reason I wasn't able to figure out the right combination of lazy/greedy matches to make it work (so I didn't even get far enough to discover the overlap issue).

Re: Advent of Code 2023 is nigh

#309

I ended up using parser combinator library nom. It's not something I use daily, therefore parsing became a puzzle on its own. Nom already has a parser for numbers. However, I didn't find an elegant way to take at most one digit. In the end I used take_while_m_n, and mapped it with u64::from_str(). Another challenge was absence of something such as find_all, that would repeatedly try to parse beginning from each chara…

Wow thanks, I was stuck with the iterating part and your solution really helped me :)

Re: Advent of Code 2023 is nigh

#310
post #212

Most solutions I see are just blobs of code, which makes me wonder what their process looks like. I like to solve these kinds of problems in Lisp, which means I'm working in a REPL and dividing and conquering the problem to be able to test one piece of the solution at a time. The result is that my code tends to be mainly independent functions that I finally string together to solve the problem.

Some folks on the subreddit will stream and then post their solutions so you can see their process. I usually enjoy watching Jonathon Paulson solve a problem after I’ve got my solution submitted. He features quite high on the leaderboard each year.

https://youtu.be/rnidYOt9m2o?si=ND_FyUJTIe-dBNrT

Post reply on HN