Novicesyntax & basics
The Flood Stone of Mill Ford
The miller at Mill Ford keeps a flood stone by the wheel: a line carved in the rock, and beside it a tally of the river's height. Each morning a notch count is written down — a positive number for notches above the line, a negative number for notches below it, and zero when the water sits exactly on the line.
The miller wants a second column beside the first: for each morning, the highest reading recorded so far, counting that morning and every morning before it.
Write highWaterMarks(marks).
marksis a list of integers, in the order the readings were taken. It may be empty.- Return a new list of the same length, where the value at each position is the largest value found at that position or any earlier position in
marks. - For an empty list of readings, return an empty list.
examples
- case 1
marks of [2, -1, 5, 3][2, 2, 5, 5] - case 2
marks of [-4, -6, -5] (a dry year, every reading below the line)[-4, -4, -4] - case 3
marks of [] (the stone was newly carved)[]
- reward
- 120 XP
- signature
highWaterMarks
TypeScript, run as ES2022 — types are stripped, not checked. If a JS engine would run it, so will we.
loading the editor…
- mixed readings
- empty stone
- single reading
- all below the line
- falling river
- rising river with zeros