‹ back to the board

Saturday, October 10

Novicesyntax & basics

The Bone-Sledges of Hrimvald Glacier

Beyond the last waystone, the only road to the Hollow Thrones of Hrimvald runs across a glacier no one may cross on foot. The Sledgewardens of Hrimvald keep a line of bone-sledges for the crossing, each drawn by a team of white elk. The Wardens will not put more riders on a sledge than it has seats, and every sledge they send out makes the full crossing, however many riders it carries.

An expedition company has posted this contract: before they set out, they need to know how many sledges to hire so that everyone gets across in one departure.

Write sledgesNeeded(party, seats), where:

  • party is a non-negative integer: the number of adventurers who must cross.
  • seats is a positive integer (at least 1): the most riders one sledge can carry.

Return an integer: the smallest number of sledges that together have at least party seats. If party is 0, return 0.

  • numeric conversion and rounding
  • Novice

examples

  1. case 1party of 7, seats of 33 (two full sledges of 3, and one more carrying the last rider)
  2. case 2party of 9, seats of 33 (three full sledges, none left over)
  3. case 3party of 0, seats of 40
reward
130 XP
signature
sledgesNeeded
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 rider needs an extra sledge
  • exact fit needs no extra sledge
  • empty party hires nothing
  • single rider on a large sledge
  • one seat per sledge
  • party smaller than seats
  • huge expedition
The Bone-Sledges of Hrimvald Glacier · bitwick