‹ back to the board

Friday, October 30

Novicesyntax & basics

The Cage-Lift of Dravenholt Mine

Deep under Dravenholt, the old silver mine has woken. Lights move in the lowest gallery where no miner has worked for a hundred years, and the Delvers' Lodge of Bitwick is sending a party down to find out why.

The only way into the lowest gallery is the iron cage-lift above the main shaft. The cage holds at most a fixed number of delvers per descent. A descent may carry fewer than that, but it can never carry more. The Lodge needs to know how many descents it will take to bring the whole party down before it hires the winch-crew.

Write descentsNeeded(party, capacity), where:

  • party is a whole number, zero or greater: the number of delvers who must reach the bottom.
  • capacity is a whole number, one or greater: the most delvers the cage can carry on a single descent.

Return a whole number: the fewest descents needed to bring every delver down. If party is zero, no descents are needed.

  • simple arithmetic
  • Novice

examples

  1. case 1party of 9, capacity of 43 descents (4 delvers, then 4, then the last 1)
  2. case 2party of 8, capacity of 42 descents (two full cages, nobody left over)
  3. case 3party of 0, capacity of 50 descents
reward
140 XP
signature
descentsNeeded
not yet run

TypeScript, run as ES2022 — types are stripped, not checked. If a JS engine would run it, so will we.

loading the editor…
  • leftover delver needs an extra descent
  • exact multiple needs no extra descent
  • empty party needs no descents
  • single delver
  • cage of one carries each delver alone
  • party smaller than the cage
  • large party
  • party exactly fills one cage
The Cage-Lift of Dravenholt Mine · bitwick