Advent of Code - Day 18

Note: This topic is to talk about Day 18 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.

1 Like

Here is my take. I solved part 2 by detecting cycles. It’s not super fast, finishes in about 7 sec. There’s some room for optimizing, but I didn’t want to uglify the code :slight_smile:

2 Likes

I had fun with streams in this one. I also implemented a cycle finding algorithm.

Running the cycle finding algorithm on the infinite stream turned out to be too slow, though, so I cheated a little by pulling out 2000 values to a finite enumerable. That is probably long enough to work for most people’s data sets. The cycle in my data starts at 452 minutes.

It finishes in about 12 minutes.

@sasajuric I liked the elegant way in which you cached the data from the infinite stream and detected the cycle at the same time.

Update: Forgot the link.

2 Likes

I caught up just in time to go on vacation: here’s my solution to Day 18:

1 Like

My solution: https://gist.github.com/marekciupak/9ab9a2d69a6f3dd6ca9b895642c61b2e.

1 Like