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.
Advent of Code 2023 is nigh
301–310 of 319 posts
Re: Advent of Code 2023 is nigh
#302I 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.
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
#303Earlier 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.
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
#304Earlier 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.
Re: Advent of Code 2023 is nigh
#305I 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
Re: Advent of Code 2023 is nigh
#306I'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
Sadly not the various help or complaint threads, or the mad lads playing up the ante, but…
Re: Advent of Code 2023 is nigh
#307As 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.
Re: Advent of Code 2023 is nigh
#308I'm going to see how far I can go with Terraform this year. Part 1 was fine, but Part 2 was a bit challenging at first.
Have Fun!
Re: Advent of Code 2023 is nigh
#309I 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…
Re: Advent of Code 2023 is nigh
#310Most 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.