‹ back to the board

Monday, October 19

Novicesyntax & basics

The Moonspan of Orrisdel Chasm

Across Orrisdel Chasm, a day's ride north of Bitwick, hangs the Moonspan: a bridge of pale light that only some travellers can walk. The Cartographers' Guild of Orrisdel pays a bounty to anyone who can say, before a traveller sets foot on it, whether the Moonspan will bear them.

The Guild's surveyors have recorded the rules exactly:

  • The bridge only exists when the moon is full or the traveller carries a lit lantern (or both).
  • The bridge bears a load of at most 50 stone. A load of exactly 50 is allowed.
  • The bridge will not bear anyone carrying iron, whatever else is true.

Write canCross(full, lit, load, iron), where:

  • full is a boolean: true if the moon is full tonight.
  • lit is a boolean: true if the traveller carries a lit lantern.
  • load is a non-negative integer: the traveller's total weight in stone.
  • iron is a boolean: true if the traveller carries any iron.

Return a boolean: true if the bridge exists and load is at most 50 and iron is false. Otherwise return false.

  • boolean expressions
  • Novice

examples

  1. case 1full moon, no lantern, load of 50, no irontrue - exactly 50 stone is still allowed
  2. case 2no full moon, lantern lit, load of 30, carrying ironfalse - iron forbids the crossing
  3. case 3no full moon, no lantern, load of 10, no ironfalse - the bridge does not exist tonight
reward
140 XP
signature
canCross
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…
  • full moon, light load
  • lantern only, light load
  • exactly 50 stone is allowed
  • 51 stone is too heavy
  • no moon and no lantern
  • iron forbids even when all else holds
  • zero load with lantern
  • no bridge and iron
The Moonspan of Orrisdel Chasm · bitwick