20
SOLUTION MEGATHREAD-❄️- 2024 Day 22 Solutions -❄️-(self.adventofcode)
submitted 1 year, 1 month ago* (edited 12 minutes after) by daggerdragon to /r/adventofcode (134.8k)
THE USUAL REMINDERS
- All of our rules, FAQs, resources, etc. are in our [community wiki](https:...
since 1 year, 1 month ago
1 of 1
Tip Reveddit Real-Time can notify you when your content is removed.
your account history
Tip Check if your account has any removed comments.
view my removed comments you are viewing a single comment's thread.
view all comments


[LANGUAGE: Go]
Today was a very welcome change of pace.
Part One: There isn't much room for any optimizations, its as easy as it can be. Just perform the given operations on each number and that's that. Since all of the "operators" are in powers of two, the corresponding operations can be converted to bit manipulation.
Part Two: I was expecting something much worse but it was quite simple(contrary to whatever yesterday was). My solution is a brute force in the sense that it maintains a cache for each 4-diff conbination to the bananas collected by all sellers. Then I can simply find the max banana yield and return it. Takes about maybe half a second to run.
One thing I messed up in part two was that I counted the same sequence for the same seller as many times as it occurred (instead of counting only once), took me a while to debug that.
Apart from that minor hiccup, this was an easy problem and I am all for it(given that I am still debugging day 21 part 2 :). Here is the solution.