‹ back to the board

Tuesday, October 27

Novicesyntax & basics

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.

  • dictionary and object access
  • Novice

examples

  1. case 1rates of {"barrow-hound": 5, "mire-lynx": 12}, kills of ["barrow-hound", "mire-lynx", "barrow-hound"]22 (5 + 12 + 5)
  2. case 2rates of {"barrow-hound": 5}, kills of ["bone-heron", "barrow-hound"]5 (the bone-heron is not on the writ, so it pays 0)
  3. case 3rates of {"mire-lynx": 12}, kills of []0
reward
130 XP
signature
tallyBounty
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…
  • repeated kills add up
  • unlisted beast pays nothing
  • no kills
  • empty writ
  • names are case-sensitive
  • zero bounty beast
  • mixed season tally
The Hunt-Writs of Skarrow Heath · bitwick