Module advent_solutions::advent2017::day17
[−]
[src]
Day 17: Spinlock
Suddenly, whirling in the distance, you notice what looks like a massive, pixelated hurricane: a deadly spinlock. This spinlock isn't just consuming computing power, but memory, too; vast, digital mountains are being ripped from the ground and consumed by the vortex.
If you don't move quickly, fixing that printer will be the least of your problems.
This spinlock's algorithm is simple but efficient, quickly consuming
everything in its path. It starts with a circular buffer containing only
the value 0, which it marks as the current position. It then steps
forward through the circular buffer some number of steps (your puzzle
input) before inserting the first new value, 1, after the value it
stopped on. The inserted value becomes the current position. Then, it
steps forward from there the same number of steps, and wherever it
stops, inserts after it the second new value, 2, and uses that as the
new current position again.
It repeats this process of stepping forward, inserting a new value,
and using the location of the inserted value as the new current
position a total of 2017 times, inserting 2017 as its final
operation, and ending with a total of 2018 values (including 0) in
the circular buffer.
Functions
| parse_input | |
| part1 |
For example, if the spinlock were to step |
| part2 |
The spinlock does not short-circuit. Instead, it gets more angry. At least, you assume that's what happened; it's spinning significantly faster than it was a moment ago. |