Day 3 proved both harder and easier than expected. At first I thought "oh this is super easy", and then I started to think more about it and was thinking "oh wait shit, this is really tricky" and then I started coding and was all "oh wait nevermind, but still harder than I originally thought"
Yeah it was an interesting one today, I got a bit sidetracked after I finished with why my parsing function was taking a long time (10ms) but I managed to optimised it to get back in line with previous days' performances
@Wipqozn Yeah, I always use regex extensively in AoC
The issue wasn't with that, it was finding which part the number was associated was slow because I was checking every single part to see if it was within the right area
I don't actually know how efficient regexes are in js, it seems comparable to other methods of searching strings but haven't actually checked how fast it is in general
Today I used regex to find all the numbers on a line, and then I figured out what their start and end coordinates are. I wasn't going to use regex originally, but it just made things a lot easier.
@Ronan Looks like we determined adjacency the same way. aka we used math checking coordinates instead of keeping a huge ass array and crawling through it. I think there were a lot of people on /r/adventofcode that used the array method, and it's making it way more difficult and error prone.
@MBraedley I considered that, but it's much easier once you know where a number is to check for symbols, whereas from a given symbol there's way more places you need to check for numbers of arbitrary length
Not all numbers have a symbol next to it, but it looks like all symbols are next to a number. My parsing sucks because it's character by character, could have done first_not_of but that would have taken more thought to get right, and then I have 3 loops that could probably get condensed.
@MBraedley Yes, but all you care about is if each number is adjacent to a single symbol.
So if you search around each symbol, you'll check some numbers multiple times. If you search around numbers, you can stop checking what's around it as soon as you find a symbol.