‹ back to the board

Sunday, October 18

Apprenticelogic & control flow

The Name-Pacts of the Corriwen Coven

Deep in the birchwoods past Bitwick, the witches of the Corriwen Coven bind familiars (owls, hares, black cats and stranger things) by giving each one a true-name. A flawed name breaks the pact on the first full moon, and the familiar turns on its keeper. The coven pays a standing bounty to anyone who can judge proposed names before the binding rite.

Write judgeName(name). It takes name, a string, and returns a string verdict.

Check the rules below in this order. Return the verdict of the first rule the name breaks. If it breaks none, return "bound".

1. "length": the name has fewer than 4 or more than 10 characters. 2. "opening": the first character is not an uppercase ASCII letter (A to Z). 3. "glyph": some character is not an ASCII letter (A to Z or a to z) or an ASCII digit (0 to 9). Spaces and punctuation break this rule. 4. "number": the name does not contain exactly one digit. 5. "echo": two adjacent characters are identical. The comparison is case-sensitive, so A followed by a is not an echo.

The return value is always one of these six strings: "length", "opening", "glyph", "number", "echo" or "bound".

  • input validation branches
  • Apprentice

examples

  1. case 1name of "Mor7ven""bound": every rule is kept
  2. case 2name of "Toff1ee""echo": the doubled f breaks the last rule
  3. case 3name of "Hoot11""number": it has two digits, and that rule is checked before the echoes of oo and 11
  4. case 4name of "" (empty)"length": too short, so no other rule is checked
reward
220 XP
signature
judgeName
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…
  • clean name is bound
  • empty name is too short
  • three characters is too short
  • four characters is allowed
  • ten characters is allowed
  • eleven characters is too long
  • lowercase opening
  • digit opening
  • opening checked before glyph
  • hyphen is a bad glyph
  • space is a bad glyph
  • no digit
  • two digits apart
  • number checked before echo
  • doubled letter echoes
  • echo at the end
  • echo is case-sensitive
The Name-Pacts of the Corriwen Coven · bitwick