The Pearl-Diver's Bell of Lunmoor Shoals
The Lunmoor Pearl Guild posts a bounty for a steady hand at the winch. Their brass diving bell is lowered into the Shoals to reach the black-pearl beds. Each turn of the winch moves the bell, and the Guild's record keeper writes every move down as a whole number of fathoms. A positive number means the bell went that many fathoms deeper. A negative number means it rose that many fathoms. The Guild wants to know the bell's depth after every turn, so its divers know when they passed the beds.
Write bellDepths(start, changes).
startis an integer: the bell's depth in fathoms before the first turn.changesis a list of integers: the moves, in the order they were made.
Return a list of integers with exactly as many entries as changes. Entry i is the depth after the first i + 1 moves have been applied to start. The value of start itself is not included in the result. If changes is empty, return an empty list.
Apply every move exactly as written. Depths may be zero or negative, and no value is capped or clamped.
examples
- case 1
start of 10, changes of [5, -3, 8][15, 12, 20]: down to 15, up to 12, then down to 20 - case 2
start of 0, changes of [-2, 2][-2, 0]: depths are not clamped, so they can go below zero - case 3
start of 4, changes of [][]: there were no moves, so there are no depths, and the start is never included
- reward
- 120 XP
- signature
bellDepths
TypeScript, run as ES2022 — types are stripped, not checked. If a JS engine would run it, so will we.
- mixed descents and ascents
- no winch turns
- single move from the surface
- depth passes through zero and below
- bell held still
- steady descent