Novicesyntax & basics
The Spent Runes of the Dunmarrow Colossus
Beneath the moor of Dunmarrow lies a stone Colossus, asleep for three hundred years. A single row of rune-stones is set down its spine, and each stone holds a charge. The Order of Tollan Wakewright pays a bounty to any adventurer who can tell its menders which stones have gone dark, so that the menders know which ones to recarve before the Colossus is roused.
A stone is spent if its charge is zero or less. A stone with a negative charge has cracked and is draining, and it counts as spent too.
Write spentRunes(charges).
chargesis a list of integers.charges[0]is the stone at the top of the spine and the rest follow in order down the spine. The list may be empty.- Return a list of integers giving the 0-based positions of every spent stone, in increasing order.
- If no stone is spent, including when
chargesis empty, return an empty list. - Do not modify
charges.
examples
- case 1
charges of [5, 0, 3, 0, 7][1, 3]: the stones at positions 1 and 3 hold no charge - case 2
charges of [-2, 1, 0][0, 2]: a negative charge is spent, just like zero - case 3
charges of [] (a spine with no stones)[]
- reward
- 140 XP
- signature
spentRunes
TypeScript, run as ES2022 — types are stripped, not checked. If a JS engine would run it, so will we.
loading the editor…
- two dark stones among lit ones
- empty spine
- no stone spent
- negative charge counts as spent
- single spent stone
- every stone spent
- single lit stone
- spent stone at the end