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).
travellersis a non-negative integer: how many people are waiting.seatsis 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].
examples
- case 1
travellers of 7, seats of 3[3, 2] — two full crossings of 3, then one carrying the last traveller, leaving 2 seats empty - case 2
travellers of 6, seats of 3[2, 0] — two full crossings, nothing left over - case 3
travellers of 0, seats of 4[0, 0] — nobody is waiting, so the punt never leaves
- reward
- 120 XP
- signature
ferryCrossings
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