Novicesyntax & basics
The Salamander Circle of Pyrewick
The Conjurers' Lodge of Pyrewick pays well for any adventurer who can say, before the chalk is drawn, whether a fire-salamander can be called into the iron circle on the cliffs tonight. A failed summoning wastes a season's worth of brimstone, so the Lodge wants a certain answer.
A salamander can be summoned when all three of these conditions hold:
1. The brazier's heat is at least 300 degrees. 2. The night is moonless, or the summoner wears a salt-iron ring, or both. 3. It is not raining.
Write canSummon(heat, moonless, ring, rain) where:
heatis an integer, the brazier's heat in degrees (it may be zero).moonlessis a boolean, true if the night is moonless.ringis a boolean, true if the summoner wears a salt-iron ring.rainis a boolean, true if it is raining.
Return a boolean: true if all three conditions hold, otherwise false.
examples
- case 1
heat of 300, moonless night, no ring, no raintrue (exactly 300 degrees is hot enough) - case 2
heat of 450, moon is up, no ring, no rainfalse (neither a moonless night nor a ring) - case 3
heat of 500, moonless night, wearing a ring, rainingfalse (rain spoils any summoning)
- reward
- 140 XP
- signature
canSummon
TypeScript, run as ES2022 — types are stripped, not checked. If a JS engine would run it, so will we.
loading the editor…
- exactly 300 degrees is enough
- one degree short fails
- ring alone suffices under the moon
- neither moonless nor ring
- rain spoils everything
- cold brazier and nothing else
- all in favour
- zero heat with everything else right