The Dryad-Gate of Ilvenwood
Deep in Ilvenwood stands a ring of ancient oaks whose roots knot together into a living gate. The dryads who tend it have pinned their terms to the Bitwick board. The Rangers' Lodge needs a quick reckoning, made before each expedition sets out, of whether a party will be let through.
The dryads open the gate to a party only when all three of these hold:
1. The party has between 1 and 6 members, inclusive. 2. The party carries no iron. 3. The party arrives at night, or carries a dryad-seal, or both.
Write mayPass(size, iron, night, seal):
sizeis an integer (zero or more): the number of members in the party.ironis a boolean:trueif the party carries any iron.nightis a boolean:trueif the party arrives at night.sealis a boolean:trueif the party carries a dryad-seal.
Return true if the gate opens for the party under the three rules above. Otherwise return false.
examples
- case 1
size of 4, no iron, arriving by day, carrying a sealtrue - case 2
size of 3, carrying iron, arriving at night, carrying a sealfalse (iron is refused no matter what) - case 3
size of 7, no iron, arriving at night, no sealfalse (the party is too large) - case 4
size of 6, no iron, arriving at night, no sealtrue (six is still allowed)
- reward
- 150 XP
- signature
mayPass
TypeScript, run as ES2022 — types are stripped, not checked. If a JS engine would run it, so will we.
- night without seal passes
- seal by day passes
- day without seal refused
- iron refused even at night with seal
- iron refused at night without seal
- six members is the upper limit
- seven members too many
- empty party refused
- lone traveller with seal