‹ back to the board

Tuesday, October 13

Novicesyntax & basics

The Silent Ferryman of Ravenmouth Ford

At Ravenmouth Ford the river runs black and fast, and only one boat crosses it: the raft of the Silent Ferryman, a hooded figure whom the Wayfarers' Guild has hired to carry its adventurers to the far bank. The Guild wants a quick reckoning of who the Ferryman will take, so that no member walks the long mud road to the ford for nothing.

The Ferryman's terms are fixed:

  • Every passenger must pay a fare of at least 3 coins.
  • Daytime runs from hour 6 up to, but not including, hour 20. Every other hour (20 through 23, and 0 through 5) is night.
  • At night, a passenger must also be carrying a lantern. By day, a lantern makes no difference.

Write mayCross(hour, lantern, coins) where:

  • hour is an integer from 0 to 23, the hour the traveller arrives at the ford.
  • lantern is a boolean, true if the traveller carries a lantern.
  • coins is a non-negative integer, the coins the traveller offers.

Return true if the Ferryman will carry the traveller under the terms above, and false otherwise.

  • boolean expressions
  • Novice

examples

  1. case 1hour of 21, carrying a lantern, 3 coinstrue - it is night, but the lantern and the fare are both there
  2. case 2hour of 20, no lantern, 7 coinsfalse - hour 20 is already night, and there is no lantern
  3. case 3hour of 12, carrying a lantern, 2 coinsfalse - the fare is one coin short
reward
150 XP
signature
mayCross
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…
  • noon without lantern, exact fare
  • night without lantern
  • night with lantern, exact fare
  • day with lantern but short fare
  • hour 20 is night
  • hour 6 is day
  • hour 5 is night even when rich
  • midnight with lantern but no coins
  • last daytime hour
  • hour 23 with lantern
The Silent Ferryman of Ravenmouth Ford · bitwick