The Lamplighter's Evening Round
The lamps along bitwick's high street are refilled each evening, and the lamplighter carries only so much oil. Before setting out she wants a list of which lamps are actually worth climbing to.
You are given fuel, a list of integers giving the oil remaining in each lamp, in order along the street, and need, an integer: the amount a lamp must hold to burn through the night.
Write shortLamps(fuel, need), which returns a list of integers: the 0-based positions of every lamp whose oil is strictly less than need, in increasing order. A lamp holding exactly need is fine and is not included. If no lamp is short, return an empty list.
examples
- case 1
fuel of [4, 1, 7, 0, 3], need of 4[1, 3, 4] - the lamp at position 0 holds exactly 4, which is enough, so it is left out - case 2
fuel of [2], need of 2[] - exactly enough counts as enough - case 3
fuel of [], need of 5[]
- reward
- 130 XP
- signature
shortLamps
TypeScript, run as ES2022 — types are stripped, not checked. If a JS engine would run it, so will we.
- mixed street
- empty street
- all lamps full enough
- every lamp short
- single lamp exactly at the mark
- single lamp one short
- negative readings count as short