-= Puzzle 2: Rollercoaster Heights =-
You run into two suspiciously familiar inventors: Feneas and Pherb (not related to anyone famous). "We've designed the ultimate rollercoaster!" Feneas exclaims, handing you a blueprint. Pherb nods, silently. "We want to advertise it as the tallest rollercoaster in the world," Feneas continues. "Can you do that for us?"
Aren't you two a bit young to be designing rollercoasters? you think to yourself. But you decide to help them out anyway.
The blueprint (your puzzle input) consists of a series of movements: Up (^
) and Down (v
). Each movement corresponds to a change in height.
The rollercoaster starts at ground level (height = 0). Each Up (^
) movement increases the height by 1 meter, and each Down (v
) movement decreases the height by 1 meter.
For example:
Blueprint: ^v^v^v^v^v
Movements: up, down, up, down, up, down, up
This blueprint results in the following heights:
1, 0, 1, 0, 1, 0, 1, 0, 1, 0
The highest point the coaster reaches in this example is 1 meter.
Because the coaster is pretty awesome, it can even descend below ground level!
Another Example:
Blueprint: ^^^v^^^^vvvvvvv
Movements: up, up, up, down, up, up, up, up, down, down, down, down, down, down, down
This blueprint results in the following heights:
1, 2, 3, 2, 3, 4, 5, 6, 5, 4, 3, 2, 1, 0, -1
The highest point the coaster reaches in this example is 6 meters.
What is the highest point the full coaster reaches?