The amount of mistakes you can make and still solve in like 2 minutes... what the heck am *I* doing?? Nice job!
@zhangtaiАй бұрын
🐐fastest uploads in the west
@fegorekАй бұрын
waiting for day 4!
@zhangtaiАй бұрын
neil im sorry for putting pressure on your uploads. every day i pray for your glorious return. take care.
@nthistlethwaiteАй бұрын
haha no worries, I just did pretty badly on day 4 (and day 5...) so I got a little demoralized and didn't feel like uploading - but it would be a little cheesy if I didn't show the bad days, so day 4 is up now! day 5 should be out pretty soon too
@God-i2Ай бұрын
🫸Competitive Programming 👉Competitive thumbnail making and video uploading
@ketz7Ай бұрын
Would it be possible to show your aoc_tools, Thank you.
@nthistlethwaiteАй бұрын
Here's a gist with the file: gist.github.com/nthistle/5244b04be6a2eae545e6908369d39592 Mostly I just use nums function, although I've occasionally used adj4 and adj8 as well. I've shadowed print because in a newer version of IDLE (which I used on my laptop last year while I was in Korea) you can't interrupt print statements, so if you accidentally put a print in a tight loop then it would kinda just freeze. The other functions like adjacent_pairs, all_pairs, all_tuples, and rolling_sum are probably useful, but I'll usually just re-write a simplified version on the fly if i want them rather than call these functions.
@harisimerАй бұрын
Part 1 you should capture the factors, that way it can be done in one line in most languages. I think thats how they got it so fast. for example c# this gives you the result: new Regex(@"mul\((\d+),(\d+)\)").Matches(input).Sum(m => int.Parse(m.Groups(1).Value) * int.Parse(m.Groups(2).Value))
@nthistlethwaiteАй бұрын
Yeah, that makes sense - mostly I just didn't remember the exact syntax for getting the capture groups from a match object in Python (and I always forget whether the first capture group is the entire match or not), and I already had my `nums` function, so I just went with what I knew. I definitely could have been faster here.
@QuotePilgrimАй бұрын
I couldn't use regex* because I'm doing it in Lua so I just wrote the stupidest looking matching pattern you can possibly imagine. (* I mean technically I could if I used an external library)
@n0ne0neАй бұрын
no day 4?
@nthistlethwaiteАй бұрын
it's up now!
@jfb-Ай бұрын
i got 99 problems so i used a regex and now i have 100 problems
@sauravmahay9838Ай бұрын
Your gonna think im stupid, but i did a slidin window thing, where the window should match a hardcoded byte array, icl this made pt2 mad quick tho... W speed tho gaadamn
@warrenhenning8064Ай бұрын
this problem is kind of a pain in the ass if you do it in a language that doesn't have regexes in the standard library :( good job!
@no_name4796Ай бұрын
Or you can not use regex and do it manually... I did it that way in golang, and it's around 30 lines of code...
@gerardomiranda2284Ай бұрын
I did it without regex as well. Not THAT hard
@QuotePilgrimАй бұрын
Not really. I did it in Lua and it was fine.
@jfb-Ай бұрын
@@QuotePilgrim lua has a pattern match system that is similar enough to regex that it works for this
@QuotePilgrimАй бұрын
@@jfb- Yes, I am aware. What do you think I've used in my solution? It is *not* "similar enough to regex", though. Sure, some approaches to the problem would be very similar using either regular expressions or Lua string matching but if you want a single pattern that matches all of "mul(123,456)", "do()" and "don't()" without also matching some things that don't quite fit the pattern, you can't really do that with Lua string matching, in regex it's just "mul\((\d+),(\d+)\)|do\(\)|don't\(\)".
@Beesman88Ай бұрын
I really disliked \d+ worked (from what i saw so far in everyones input) I never write regex right first time without googling or testing, so i had to find the {lower,upper} count syntax since my brain didn't remember it, yet it would reward me for not reading the constraint of 1-3 digits since \d+ my brain does remember..
@FirSouL3Ай бұрын
Yep, they should have added at least a test case with a number higher than 999, otherwise why even mention that it should have 3 digits at most?
@nthistlethwaiteАй бұрын
Ah yeah I didn't even notice the 1-3 digits constraint until well after I had solved. I probably would have been in a similar boat as you if I did see it, since I also didn't remember how to do a range for number of characters to match.