Novicesyntax & basics
The Griffon Flight to Skarrow Isle
The Aerie Mistress of Kestrel Scar has posted a commission: a company of adventurers must be flown across the Gloaming Sound to Skarrow Isle before the autumn gales close the sky. Every griffon in the aerie wears the same saddle, and each saddle holds a fixed number of riders. All the riders fly in a single crossing, so every rider needs a seat on some griffon.
Write griffonsNeeded(riders, seats), which returns the smallest number of griffons needed to carry every rider.
ridersis a whole number, 0 or greater: how many adventurers must cross.seatsis a whole number, 1 or greater: the most riders a single griffon can carry.
Return a whole number. A griffon may fly with fewer riders than it has seats. If there are no riders, no griffons are needed.
examples
- case 1
riders of 7, seats of 24 (three full griffons, and a fourth carrying the last rider alone) - case 2
riders of 8, seats of 24 (every griffon full, none to spare) - case 3
riders of 0, seats of 30
- reward
- 140 XP
- signature
griffonsNeeded
TypeScript, run as ES2022 — types are stripped, not checked. If a JS engine would run it, so will we.
loading the editor…
- leftover rider needs another griffon
- exact fill needs no extra
- no riders means no griffons
- single rider on a large saddle
- riders exactly match one saddle
- single-seat saddles
- large company
- one short of a full flight