‹ back to the board

Friday, October 16

Novicesyntax & basics

The Torch-Tally of Greymantle Delve

The Cartographers' Guild of Bitwick is sending an expedition into Greymantle Delve, a mine shaft abandoned so long ago that no daylight reaches past its mouth. The expedition must carry its own light. The Guild's quartermaster will pay for an exact tally of torches, so that the party neither runs dark nor hauls dead weight.

The torches are lit one at a time. A new torch is lit the moment the previous one burns out. Every torch burns for the same number of minutes. A torch that is only partly used up when the expedition ends still had to be carried, so it counts as a whole torch.

Write torchesNeeded(minutes, burn).

  • minutes is a non-negative integer: how many minutes the expedition will spend in the Delve.
  • burn is a positive integer (at least 1): how many minutes a single torch burns.

Return an integer: the smallest number of torches whose combined burn time is at least minutes. If minutes is 0, no torches are needed and the answer is 0.

  • simple arithmetic
  • Novice

examples

  1. case 1minutes of 100, burn of 304 (three torches give only 90 minutes, so a fourth is needed for the last 10)
  2. case 2minutes of 60, burn of 601 (one torch covers the expedition exactly)
  3. case 3minutes of 0, burn of 450
reward
140 XP
signature
torchesNeeded
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…
  • exact multiple of burn time
  • leftover minutes need one more torch
  • zero minutes needs no torches
  • one minute still needs a whole torch
  • minutes equal to one torch
  • one minute past a single torch
  • one-minute torches
  • torch longer than expedition
The Torch-Tally of Greymantle Delve · bitwick