The Rune-Golems of Mirethorn Quarry
Deep in the cuttings of Mirethorn Quarry stand the Rune-Golems, carved and bound by the Quarry-Wardens' Guild. The Guild keeps a ledger of every golem still whole, with the might carved into its brow. Before an expedition sets out into the wild, the Guild reads out a call of golem names to wake. Some names on the call belong to golems shattered long ago. Those names are no longer in the ledger, and those golems do not rise.
The contract: tell the expedition how much might will march with it.
Write wakeMight(ledger, names):
ledgeris a dictionary (object) mapping each golem's name (a string) to its might (a non-negative integer).namesis a list of strings, the names on the call. No name appears more than once innames.
Return an integer: the sum of the might of every name in names that is a key in ledger. A name that is not a key in ledger adds 0. Names are matched exactly, so "slatefist" and "Slatefist" are different names. If names is empty, return 0.
examples
- case 1
ledger of Granitebrow 7, Slatefist 4, Mossjaw 9; names Granitebrow and Mossjaw16 - case 2
ledger of Granitebrow 7, Slatefist 4, Mossjaw 9; names Slatefist and Cinderhulk (Cinderhulk is not in the ledger)4 - case 3
ledger of Granitebrow 7; names is empty0
- reward
- 140 XP
- signature
wakeMight
TypeScript, run as ES2022 — types are stripped, not checked. If a JS engine would run it, so will we.
- two golems found
- one name missing from ledger
- empty call
- empty ledger
- case-sensitive names
- golem of zero might
- all names missing
- whole ledger called