Advent of Code - Day 7



Note by the Moderators: This topic is to talk about Day 7 of the Advent of Code.

For general discussion about the Advent of Code 2018 and links to topics of the other days, see this topic.


Here’s my take on day7. I implemented the first part as a special case of part two (using just one worker). This makes part 1 less optimal, but the running time is still good enough.

The curiosity of my approach is that I made a stream which emits all intermediate states. Part 1 then boils down to taking the last state and fetching the processed items. Part 2 amounts to counting all the states and decrementing it by one.