The Rope-Span of Thessen Gorge
The Rope-Span over Thessen Gorge is old hemp and older planks. The Wardens of the Span will let a pack-mule cross only if the crate on its back weighs no more than the span's posted limit. The Pellwick Mule-Train has halted at the near edge, and its drover needs to know which mules must be unloaded before the crossing.
Write overloadedMules(loads, limit).
loadsis a list of non-negative integers. Each entry is the weight carried by one mule, in the order the mules stand in the train. The first mule is at position0.limitis a non-negative integer, the heaviest load a single mule may carry across.
Return a list of the zero-based positions of every mule whose load is strictly greater than limit, in increasing order. A mule whose load is exactly equal to limit may cross and is not listed. If no mule is over the limit, including when loads is empty, return an empty list.
examples
- case 1
loads of [12, 30, 25, 31, 8], limit of 25[1, 3]. The mule at position 2 carries exactly 25, so it may cross. - case 2
loads of [10, 10, 10], limit of 10[]. Every load equals the limit, so every mule may cross. - case 3
loads of [] (no mules), limit of 10[]
- reward
- 130 XP
- signature
overloadedMules
TypeScript, run as ES2022 — types are stripped, not checked. If a JS engine would run it, so will we.
- mixed train with one load exactly at the limit
- empty train
- all loads equal the limit
- zero limit flags every loaded mule
- single mule just over
- empty crates and repeated heavy loads
- zero limit with empty crates