The Hunt-Writs of Skarrow Heath
The Wardens of Skarrow Heath post a hunt-writ each season. The writ lists the beasts the Wardens will pay to have culled and the bounty, in silver, for each one. A returning hunter brings back a tally of every beast they brought down. Each kill of a listed beast pays that beast's bounty. A kill of a beast that is not on the writ pays nothing.
Write tallyBounty(rates, kills), which returns the total silver the hunter is owed.
Arguments - rates: a dictionary (object) that maps beast names (strings) to their bounty in silver (non-negative integers). - kills: a list of beast names (strings). There is one entry per kill, and the same name may appear many times.
Return - An integer. It is the sum of the bounty for every entry in kills. A name that is not a key in rates adds 0.
Rules - Names match exactly, including upper and lower case. "Mire-Lynx" and "mire-lynx" are different beasts. - If kills is empty, return 0. - Do not modify rates or kills.
examples
- case 1
rates of {"barrow-hound": 5, "mire-lynx": 12}, kills of ["barrow-hound", "mire-lynx", "barrow-hound"]22 (5 + 12 + 5) - case 2
rates of {"barrow-hound": 5}, kills of ["bone-heron", "barrow-hound"]5 (the bone-heron is not on the writ, so it pays 0) - case 3
rates of {"mire-lynx": 12}, kills of []0
- reward
- 130 XP
- signature
tallyBounty
TypeScript, run as ES2022 — types are stripped, not checked. If a JS engine would run it, so will we.
- repeated kills add up
- unlisted beast pays nothing
- no kills
- empty writ
- names are case-sensitive
- zero bounty beast
- mixed season tally