The Fog-Ferry of Marrowfen
Beyond the last waymarker of Bitwick lies Marrowfen, a black marsh crossed by a single flat-bottomed ferry. It is poled by the Fenwarden, who takes adventurers across to the drowned barrows on the far shore under fixed terms. The Bitwick board seeks someone to write those terms down, so that parties stop wading out to the landing only to be turned away.
Write canCross(party, charm, fog, iron), which decides whether a party may board the ferry tonight.
Arguments: - party: an integer, zero or more, giving the number of adventurers in the party. - charm: a boolean, true if the party carries a ward-charm. - fog: a boolean, true if fog lies on the fen tonight. - iron: a boolean, true if anyone in the party carries cold iron.
Return a boolean. It is true only if all three of these hold: 1. party is between 1 and 4, inclusive. 2. iron is false. 3. charm is true, or fog is false, or both.
If any of the three fails, return false.
examples
- case 1
party of 4, no charm, fog on the fen, no ironfalse (fog without a ward-charm) - case 2
party of 4, a ward-charm, fog on the fen, no irontrue - case 3
party of 2, no charm, clear night, but one carries cold ironfalse - case 4
party of 0, a ward-charm, clear night, no ironfalse (an empty party cannot board)
- reward
- 150 XP
- signature
canCross
TypeScript, run as ES2022 — types are stripped, not checked. If a JS engine would run it, so will we.
- clear night, plain party
- fog without charm
- fog with charm, full raft
- empty party
- too many aboard
- iron with charm
- iron on a clear night
- lone adventurer, clear night
- charm on a clear night
- everything wrong