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).
legendis a dictionary (an object in TypeScript) mapping symbol strings to terrain names, e.g.{"^": "mountain", "~": "river"}.routeis 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.
examples
- case 1
legend of {"^": "mountain", "~": "river", "T": "forest"}, route of ["T", "~", "^"]["forest", "river", "mountain"] - case 2
legend of {"^": "mountain", "~": "river"}, route of ["^", "?", "~"]["mountain", "uncharted", "river"] - "?" is not in the legend - case 3
legend of {"M": "marsh"}, route of ["M", "m"]["marsh", "uncharted"] - lowercase "m" is a different symbol
- reward
- 130 XP
- signature
readRoute
TypeScript, run as ES2022 — types are stripped, not checked. If a JS engine would run it, so will we.
- all symbols known
- unknown symbol in the middle
- empty route
- empty legend
- symbols are case-sensitive
- repeated symbols
- single league