26 Commits

Author SHA1 Message Date
04af300e95 Day 25 solution
Got global rank 707/592 on this one. My best yet!
2021-12-24 23:20:42 -06:00
a2a5921219 Finally a Day 21 part 2 solution
I was making this way too hard.
2021-12-24 22:39:33 -06:00
f29dd5efa0 Day 24
I solved this by hand, so there's no code solving it programmatically. Maybe I'll come back later and solve it with code...
2021-12-24 15:19:49 -06:00
39ec926909 Day 23
It's not my proudest work, but it gets the answer in 15 seconds or less on my machine which, while far slower than pretty much any other day, is a huge improvement over my initial attempts that took 30+ minutes. There is a lot of low-hanging fruit that could be used to improve this runtime, mostly around filtering possible moves and the Amphipod hashing function for memoization, but I am spending that time prepping for day 24 (and eventually finishing day 21 part 2...).

My "coordinate" system is hideous and I feel bad about it, as is my handling of part 2 vs part 1 w.r.t. adding two new rows. But I didn't want to manufacture some kind of 2d grid that had a bunch of closed-off spaces, so I just made this awful thing work instead. I have an easier time thinking in discrete "1d" chunks than I do thinking in 2d graphs anyway. I would also love to add a stack to be able to replay the moves that got us to a solution, but again, I'm trying to move on! :)
2021-12-23 22:19:24 -06:00
f0e1bec95b Day 22 solution 2021-12-22 10:22:04 -06:00
8a6bf8604a Day 21 part 1 and WIP for part 2
I also improved the main startup code to require a little less maintenance.
2021-12-21 22:51:21 -06:00
60d61584c8 Day 19 solution
Cribbed heavily from https://www.reddit.com/r/adventofcode/comments/rjpf7f/comment/hp5k554/?utm_source=share&utm_medium=web2x&context=3 because this problem breaks my brain in so many ways. I understand the approach, but I got twisted up in my own head trying to write down the solution, so instead I started from a working copy and optimized it (a little bit) to make sure I understood what it was doing.
2021-12-20 15:37:41 -06:00
8a33549ad2 Day 20 solution
I would have had this done last night, but... _unintelligible muttering about key[0] being '#' in the real input and '.' in the sample...

Day 19 is...still vexing me. Maybe I'll get back to it later.
2021-12-20 09:09:43 -06:00
fd0fd238f7 Day 18 solution
I have a very strong feeling that I massively over-complicated this, but it works. I spent a ton of time making sure each component of the problem was implemented correctly so I could quickly identify where things went wrong, and that setup was convenient enough that I just formalized it and left it in. Maybe it'll be useful for another day...
2021-12-18 16:23:54 -06:00
4062039bad Day 17
I've done better. I've done worse. ¯\_(ツ)_/¯
2021-12-17 10:20:18 -06:00
542df5bd8c Day 16, extreme parsing edition 2021-12-16 09:23:08 -06:00
5f830051e8 Day 15 solution
Heavily cribbed from https://github.com/encse/adventofcode/blob/master/2021/Day15/Solution.cs but transformed to be more my style. At its core, this is just "implement Dijkstra", so I feel no shame in using an existing implementation of a known algorithm. :)
2021-12-15 10:50:33 -06:00
bd6038c837 Day 14 initial solution
Part 1 brute force, part 2 solved "correctly" (I think, anyway). This day runs slower than I would expect, given how little part 2 is doing.
2021-12-14 12:01:35 -06:00
4b9ff1c4bd Day 13 solution
Honestly I think I have an error somewhere in the part 2 logic because my final output characters weren't exactly correct, but they were close enough that my first guess for each letter was right. So I may revisit this to find and fix the logic bug, but apparently it's Close Enough™ to be done for the night.
2021-12-12 23:58:42 -06:00
0dc2abeca9 Day 12 solution
This was my initial solution I used to submit the puzzle answer. Runtime for part 2 on my input set was around a second, so now I'm going to find optimization targets. I'm sure there's a lot I could be doing much better.
2021-12-12 10:08:46 -06:00
a522b93f9b Day 11 solution
Pretty happy with this one overall. I tripped myself up on part 2 and caused a huge headache by not realizing that I was passing the already-modified array from part 1 into part 2. I left some code to copy the 2d array because that was my original solution (and it's not straightforward to copy jagged arrays), but then realized that the synchronized flash doesn't happen until after step 100 (at least for my input and the demo input) so we can just account for that in part 2 and pick up where part 1 left off.
2021-12-10 23:49:32 -06:00
55b385f779 Day 10 solution
I actually feel pretty good about this one.
2021-12-09 23:23:49 -06:00
2c224483b4 Day 9 solution
As always, plenty of room for improvement, but I'm reasonably satisfied with the core implementation. I'm honestly not sure why the Distinct is needed in the GetBasinSize() result as it's supposed to not even add the point if the point is already in there, but it's late so I'll check that out later.
2021-12-09 00:40:02 -06:00
1330d1eb66 Day 8
I hate almost everything about this solution. It's all awful and a product of constantly adjusting how I was solving the problem to try and get the correct answer, so there are vestigial pieces of each road I headed down. Then I ended up using some combination of all of those pieces to get the actual answer, and...well it just needs to be overhauled dramatically. But it works, so I guess mission accomplished.
2021-12-08 10:57:36 -06:00
cfb3c668c7 Day 7 solution
I'm reasonably happy with this one. I'm sure there's an easier way to determine the smallest distance, at least for part 1, but this works fast enough for me.
2021-12-07 07:56:11 -06:00
2cc95c6e8e Day 6 solution
Took me a while to come to the fast solution, but I got there.
2021-12-05 23:55:15 -06:00
7d93691276 Day 5 solution
There is a lot to be disliked here, starting with the Line Length calculation, which I'm sure I'm just totally overthinking or otherwise being dumb about, to the way I'm picking the next point while moving along the line.

Also, TIL how much of a difference a good GetHashCode() override can make when comparing/equating custom struct instances. Not implementing GetHashCode() on this solution resulted in ~250ms runtime on my PC. Implementing a "bad" GetHashCode() (which was `return x.GetHashCode() | y.GetHashCode();` which seemed fine to me ¯\_(ツ)_/¯) resulted in >1s runtime on my PC. Using this implementation (HashCode.Combine()) results in ~25ms runtime on my PC. Those numbers are with nothing changing other than the implementation of GetHashCode() on struct Point.

I also disabled nullability in my quest to improve performance here. The compiler was complaining that my Equals() override wasn't equivalent because of nullability, so it had to be `object? obj` which I didn't care for since this was a value type and not a reference type.
2021-12-05 11:19:13 -06:00
3dc7e1ccde Day 04 in javascript
This is a lot of copy/paste, but I am on a time crunch this morning so I'll clean it up later!
2021-12-05 11:19:10 -06:00
12b004c724 Day 3 solution. Not clean, but oh well. 2021-12-03 10:00:48 -06:00
83e16885c7 Day 2 solution in C# 2021-12-02 10:03:00 -06:00
1da6d83760 Day 1 solution in Rust
I have no idea what I'm doing in Rust, and I definitely don't understand
borrowing yet, so this is a hideous solution on multiple fronts. I'm not
sure that I'll be sticking with Rust as AoC doesn't feel like a
conducive environment to learn it in.
2021-12-01 08:00:40 -06:00