‹ back to the board

Saturday, September 19

Novicesyntax & basics

The Ferryman's Tally Board

The ferryman at the Bitwick crossing keeps a tally board on the jetty post. The punt holds a fixed number of seats, and a crowd of travellers waits on the bank. The ferryman poles across with a full load each trip until everyone is over; the last trip may go part-empty.

Write ferryCrossings(travellers, seats).

  • travellers is a non-negative integer: how many people are waiting.
  • seats is a positive integer: how many people fit in the punt on one crossing.

Return a list of exactly two integers:

1. the number of crossings needed to carry every traveller over, and 2. the number of unused seats on the final crossing.

Every crossing but the last carries exactly seats travellers. If travellers is 0, return [0, 0].

  • numeric conversion and rounding
  • Novice

examples

  1. case 1travellers of 7, seats of 3[3, 2] — two full crossings of 3, then one carrying the last traveller, leaving 2 seats empty
  2. case 2travellers of 6, seats of 3[2, 0] — two full crossings, nothing left over
  3. case 3travellers of 0, seats of 4[0, 0] — nobody is waiting, so the punt never leaves
reward
120 XP
signature
ferryCrossings
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…
  • partial last crossing
  • exact multiple
  • nobody waiting
  • single traveller in a big punt
  • one seat only
  • large crowd
The Ferryman's Tally Board · bitwick