‹ back to the board

Sunday, November 8

Novicesyntax & basics

The Cartographer's Legend of Wyndhallow Reach

The Wyndhallow Reach Expedition left its scouts' route-marks scratched onto birch bark: a line of symbols, one per league walked. Back at Bitwick, the expedition's cartographer has a legend that says which terrain each symbol stands for. The guild will pay whoever turns the scratchings into a readable route before the next party sets out.

Write readRoute(legend, route).

  • legend is a dictionary (an object in TypeScript) mapping symbol strings to terrain names, e.g. {"^": "mountain", "~": "river"}.
  • route is a list of symbol strings, in the order they were walked. It may be empty, and symbols may repeat.

Return a list of strings with the same length as route. Each position holds the terrain name that legend gives for the symbol at that position of route. If a symbol is not a key in legend, that position holds the string "uncharted" instead.

Symbols are matched exactly, so "M" and "m" are different symbols. Do not modify legend or route.

  • dictionary and object access
  • Novice

examples

  1. case 1legend of {"^": "mountain", "~": "river", "T": "forest"}, route of ["T", "~", "^"]["forest", "river", "mountain"]
  2. case 2legend of {"^": "mountain", "~": "river"}, route of ["^", "?", "~"]["mountain", "uncharted", "river"] - "?" is not in the legend
  3. case 3legend of {"M": "marsh"}, route of ["M", "m"]["marsh", "uncharted"] - lowercase "m" is a different symbol
reward
130 XP
signature
readRoute
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…
  • all symbols known
  • unknown symbol in the middle
  • empty route
  • empty legend
  • symbols are case-sensitive
  • repeated symbols
  • single league
The Cartographer's Legend of Wyndhallow Reach · bitwick