re: branch cutting
thanks for the tip, I looked into it again and I found I was cutting in the wrong place. Fixed now, and halves the time for part 2
re: branch cutting
thanks for the tip, I looked into it again and I found I was cutting in the wrong place. Fixed now, and halves the time for part 2
Re: day 7 parts 1 and 2
same here, I was dicking around with combinatorics to get all combos of plus and multiply but realized before I got to the end it was gonna take too long. Then I figured that a DFS was the way to go.
I tried to optimize a bit by exiting early if the cumulative result became too large, but for some reason that gave me incorrect (too low) answers. Part 2 runs in around 1 min anyway.
https://github.com/gustafe/aoc2024/blob/main/d07-Bridge-Repair.pl
Yes, the person briefly changed their username and then left the site (disowning their comments). There are 2 people with "inactive-user" comments in the thread that simply flounced off to greener pastures.
day 6
part 2
I also brute-forced this. I figured there's a bit optimization to be done if you "draw a line" to the next obstacle instead of going step by step, and also maybe exclude some areas, but in the end I just set an exit value to break if the number of steps exceeded a certain value and say that was a loop. Took almost 20m but a star is a star.
update I only added obstructions in the original path, which cut the time down to 5 minutes or so.
An update, a user stated, "with all love and respect": "people will not starting hating Brave but they will start to hate the mod who blocked Brave".
2 hours later they'd removed their account.
day 5
urgh this took me much longer than it should have... part 1 was easy enough but then I got tied up in knots with part 2. Finally I just sorto-bogo-sorted it all into shape
Perl: https://github.com/gustafe/aoc2024/blob/main/d05-Print-Queue.pl
Recheck array size: 98
All rechecks passed after 5938 passes
Duration: 00h00m00s (634.007 ms)
Ed's intended audience is probably more familiar with Beckett's play than some random indie game engine.
re: 4-2
is it really n^2 tho? You have to do a constant check around each element, but that does not increase with the number of elements. And you can optimize a bit by marking already seen 'A's as illegal states and don't have to check them when the next row is processed.
discussion
There's probably a smarter way to do this...
For part 1, I dumped everything into a matrix. Then I scanned it element by element. If I found an X, I searched in 8 directions from there and counted up if I found M A S in sequence.
For part 2 I searched for an A, checked each diagonal corner, and counted up if the opposites were M S or S M
https://github.com/gustafe/aoc2024/blob/main/d04-Ceres-Search.pl
And right now South Korea's president has declared martial law and banned all political activity, I guess she'll be just fine with that.
day 8 part 2
Eric added some
0
s in the grid which fucked up my existence code, sneaky devil