‹ back to the board

Monday, November 2

Novicesyntax & basics

The Bounty Schedule of Sarnwold Marches

The Warden of the Sarnwold Marches nails a bounty schedule to the board each season. It lists every beast of the fens the Warden will pay for, and how many silver pieces each trophy is worth. Hunters come back from the mists with sacks of trophies, and some of those trophies are from beasts the Warden never asked for.

Write bountyTotal(schedule, trophies).

  • schedule is a dictionary (object) that maps a beast's name (a string) to the bounty paid for one trophy of that beast (a non-negative integer).
  • trophies is a list of strings. Each string is the name of the beast one trophy was taken from. The same name may appear more than once.

Return the total silver, as an integer, owed for all the trophies. Each trophy whose name is a key in schedule earns that key's value, once per appearance in the list. A trophy whose name is not a key in schedule earns 0. Names must match exactly, including capitalisation. If trophies is empty, return 0.

  • dictionary and object access
  • Novice

examples

  1. case 1schedule of { "ghoul": 5, "barghest": 12, "marsh-imp": 2 }, trophies of ["ghoul", "ghoul", "barghest"]22 (5 + 5 + 12)
  2. case 2schedule of { "ghoul": 5, "barghest": 12 }, trophies of ["ghoul", "wyvern", "Ghoul"]5 ("wyvern" is not on the schedule, and "Ghoul" does not match "ghoul")
  3. case 3schedule of { "ghoul": 5 }, trophies of []0
reward
140 XP
signature
bountyTotal
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 and mixed trophies
  • no trophies brought
  • unlisted beast earns nothing
  • empty schedule
  • capitalisation must match
  • zero-value bounty
  • single trophy
  • long haul
The Bounty Schedule of Sarnwold Marches · bitwick