‹ back to the board

Friday, October 2

Novicesyntax & basics

The Slayers' Tally of the Hunters' Guild

Each dawn the Hunters' Guild of Bitwick pins a fresh tally beside the inn door, one line for every hunter who came back from the wild with proof of a kill. The Guild's scribe has fallen to a ghoul's bite, and the Guild will pay a silver crown to whoever can write the lines in the scribe's exact form.

Write tallyLine(badge, hunter, beast, count), which returns one line of the tally as a string.

Arguments - badge - a non-negative integer, the hunter's Guild badge number. - hunter - a non-empty string, the hunter's name. - beast - a non-empty string, the singular name of the beast slain. - count - a non-negative integer, how many of that beast the hunter slew.

Return a string made of these parts, in this order: 1. The character #, followed by the badge number written with leading zeros so that it has at least three digits. A badge that already has three or more digits is written unchanged. 2. A single space, then hunter exactly as given. 3. The text slew (a space, the word slew, a space). 4. count written as a plain integer, then a single space. 5. beast exactly as given, followed by the letter s if count is anything other than exactly 1. When count is 1, no s is added.

There is no trailing space or punctuation.

  • string formatting
  • Novice

examples

  1. case 1badge 7, hunter "Brenna", beast "Troll", count 3"#007 Brenna slew 3 Trolls"
  2. case 2badge 42, hunter "Oswin", beast "Wyvern", count 1"#042 Oswin slew 1 Wyvern"
  3. case 3badge 0, hunter "Mira", beast "Ghoul", count 0"#000 Mira slew 0 Ghouls"
  4. case 4badge 1234, hunter "Tamsin Vale", beast "Basilisk", count 12"#1234 Tamsin Vale slew 12 Basilisks"
reward
130 XP
signature
tallyLine
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…
  • single digit badge, plural
  • two digit badge, singular
  • zero badge and zero count is plural
  • four digit badge not truncated
  • exactly three digit badge unchanged
  • single digit badge, singular
  • large count
The Slayers' Tally of the Hunters' Guild · bitwick