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:
fullis a boolean:trueif the moon is full tonight.litis a boolean:trueif the traveller carries a lit lantern.loadis a non-negative integer: the traveller's total weight in stone.ironis a boolean:trueif 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.
examples
- case 1
full moon, no lantern, load of 50, no irontrue - exactly 50 stone is still allowed - case 2
no full moon, lantern lit, load of 30, carrying ironfalse - iron forbids the crossing - case 3
no full moon, no lantern, load of 10, no ironfalse - the bridge does not exist tonight
- reward
- 140 XP
- signature
canCross
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