‹ back to the board

Thursday, October 15

Novicesyntax & basics

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):

  • ledger is a dictionary (object) mapping each golem's name (a string) to its might (a non-negative integer).
  • names is a list of strings, the names on the call. No name appears more than once in names.

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.

  • dictionary and object access
  • Novice

examples

  1. case 1ledger of Granitebrow 7, Slatefist 4, Mossjaw 9; names Granitebrow and Mossjaw16
  2. case 2ledger of Granitebrow 7, Slatefist 4, Mossjaw 9; names Slatefist and Cinderhulk (Cinderhulk is not in the ledger)4
  3. case 3ledger of Granitebrow 7; names is empty0
reward
140 XP
signature
wakeMight
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…
  • 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
The Rune-Golems of Mirethorn Quarry · bitwick