The Climbers' Log of the Thornspire Ash
Far past the last farmsteads of Bitwick stands the Thornspire Ash, a tree so tall its crown is lost in cloud. The Guild of Bough-Wardens is sending a roped party up its trunk. At each nightfall the party's scribe records one whole number: how far the camp moved since the night before, measured in spans. A positive number means the party climbed higher. A negative number means it slid or climbed back down. Zero means it held its place.
The Guild wants the height of every camp written out in order, so the next party knows where the safe ledges are.
Write chartAscent(start, changes).
startis an integer: the party's height in spans when the climb began.changesis a list of integers, one for each day in order: that day's change in height.
Return a list of integers with the same length as changes. Element i is the party's height at the end of day i. That is start plus the sum of the changes from the first day through day i. Do not include the starting height itself. If changes is empty, return an empty list. Heights may be zero or negative.
examples
- case 1
start of 100, changes of [5, -3, 10][105, 102, 112] - case 2
start of -20, changes of [10, 10, 10, -5][-10, 0, 10, 5] - case 3
start of 30, changes of [] (the party never set out)[] (the starting height is not recorded on its own)
- reward
- 120 XP
- signature
chartAscent
TypeScript, run as ES2022 — types are stripped, not checked. If a JS engine would run it, so will we.
- mixed climb
- no days logged
- single day down to zero
- negative start crossing zero
- holding in place
- long descent below the roots