What are you coding?

what approach did you do?

2 Likes

AoC day 22

Ah now that’s a bit more like it.

After a fairly straightforward shift-mod sequence, part 2 is an exhaustive search, but I save some time by only storing the information I need: for each starting number, the first time I see a particular changeset, I add its value to the total for that changeset. Then it’s just a matter of pulling out the highest total. For later calculations, it doesn’t matter which or how many sequence numbers participate, so I don’t store that information.

Recursive pathfinding. I think I just need to optimize for some edge cases

2 Likes

I can‘t help with the recursion (i regret that, i wish i had not iterated) and I can‘t help with pathfinding because I omitted that and did it manually.

I have managed to do quite a few optimizations on my code and I hope to introduce one more that might shave off enough time to make the additional runtime bearable. But I doubt it will be enough,

2 Likes

I did go recursive for 21, and similarly had some off-by-a-small-number errors on the test data. In my case it was incorrect encoding of the keypad layouts, and particularly in detecting a move that might traverse the empty space.

2 Likes

I think I might have over-optimized the gap-avoidance and need to prioritize pointing at A higher

2 Likes

Absolutely, being next to A is gooood!

1 Like

AoC Day 22

Part 1 is surprisingly straightforward for a Day 22, especially a weekend. Maybe they are acknowledging that people get busy close to Christmas? Probably not and it’s just a fluke.

For Part 2 I leverage python’s deque and it’s max_len feature that appears even faster than slicing; and then also a hashmap of sets to avoid too many transactions with a given (enumerated) monkey

2 Likes

I finished today’s part 1 easily … and the most difficult thing for part 2 was getting down from the optimizing train I had hopped on while working on Day 21.2 this morning.

I did manage to shave off quite a lot of time from 21.2 btw… my patience now lasts until cycle 18 (4 seconds which I think is quite fast) and 20 takes 30 seconds… so each additional cycle slightly more than doubles runtime. I should just wait it out. (I also might run out of heapspace… )

My first this year:

2 Likes

AoC day 23

Quite a lot of false starts on this one; for part 1, I thought the question was asking for sets of three that weren’t connected to the larger network and tried to use graph partitioning.

Then for part 2 it became clear that pathfinding wasn’t going to be a consideration, but my order-free sets turned out to be the wrong approach. In the end I work internally on the node indices (assigned ad-hoc as they come up in the connection list), and when considering something add to an existing set only look at nodes with higher indices than any of those already in the set.

Also it’s much easier to encode the node names as base-36 numbers, which can be transparently copied and cloned, than to work with strings, which can’t.

2 Likes

Yeeeeessss!
I correctly anticipated most of what part 2 of Day 23 would do and it took me all of 1 line of code to get the right solution to part 2 on the first try! I don’t think I ever did that this year for any part 2 never mind one this late in the advent of code! I did struggle a bit needlessly with part 1 of course… but I am pretty pleased with myself for part 2 :slight_smile:

2 Likes

AoC unofficial participation survey..

2 Likes

Day 24.1 was nice… I’ve programmed this kind of pattern often enough that it was quite fun to do this one. I haven’t even read the text for part 2 really. My biggest mistake was string sorting the output and … having to reverse the number :wink:

It’s been fun. No idea when I’ll find time to do more of the puzzles because now the holidays will eat up my time.

Happy coding and happy celebrating to you :slight_smile:
Thanks for doing this again here, I love these puzzles–sometimes not in that particular moment but overall it’s been great fun again.

3 Likes

AoC day 24

Ooh, now this was a really enjoyable one. Felt about as hard as 21, but it was always being fun rather than tedious edge-cases.

Part 1 was quite fun in itself, mostly in terms of deriving a reasonably efficient data structure. (All right, I’m not sure I might not have done better by deleting gates after they were activated. Or building a queue. Or something.)

Part 2 came apart into three programs and some human intervention between them.

Given that this is a reasonably efficient binary adder, any Z value must be the result of an XOR. Any gate that doesn’t produce a Z value, and doesn’t take an X or Y value as input, cannot be a XOR. So any gate that deosn’t satisfy those constraints is clearly dodgy. ba lists those. I note that I have three pairs out of the four I need.

bb takes the input, applies any swaps, and produces a GraphViz file which I then plot with neato. Given those swaps from ba, I can see by looking at the output which nodes are near each other and therefore need to be exchanged. (Populating swaps lets me redraw the diagram to check.)

For my input data that gives me three of the swaps, so just one more to find. bc steps through possible input values: in binary, 1 + 1 = 10, 10 + 10 = 100, etc. It stops when it gets a wrong answer. (I might have used more complex patterns involving the incoming carry, e.g. 11 + 11 = 110, but at least with my input I didn’t have to.) That shows me where in the diagram I need to look, and thus what the fourth swap pair should be. And the first thing bc does is check that the official inputs add up correctly, so it’s a verifier for the final pair too.

1 Like

AoC Day 24

Part 1

That was fun. I made classes. :slight_smile:

Part 2

:expressionless:
I wrote code to generate a visualization and then figured it out from pattern-recognition.

2 Likes

I think I could have automated ¾ of part 2 relatively easily, but the last one needed the same thing you did.

1 Like