Advent of Code - Day 5

 read in about 1 minute

If only we hadn’t switched to the new inventory management system right before Christmas!

Part 1

In this part we’re asked to check if an ID is within a range and count the number where this is true. This was not very difficult. Similar to other challenges read in the lines, split them along the “,” delimiter, and use these ranges to confirm if the later list is fresh or not.

Got a comment about this possible syntax so I used this instead of two expressions with and inbetween.

 if fresh[0] <= id <= fresh[1]:

This is a pretty useful simplification where I think some other examples I’ve seen can be a bit obfiscating and confusing.

Part 2

The second part is a count of all ingredient IDs that are fresh. I spent a bunch of time overcomplicating this problem. Eventually I threw it all out and started blank and eventually got there. The solution isn’t even interesting to share here. Just a reminder for myself to not complicate things.

Listening to: Walk On By - Thundercat
Christopher Himes

I'm Christopher Himes (he⁠/⁠him), an accomplished tech professional living in Metro Detroit. I'm currently looking for work as a product owner or developer.

More about me

Comments

This blog uses a Mastodon and webmentions for comments. You can comment by replying on Mastodon/ActivityPub/Fediverse account or webmention.

Related Posts

Recent Posts