‹ back to the board

Monday, October 26

Novicesyntax & basics

The Salt-Caravan of Dunmarrow Waste

The Salt-Caravan of Dunmarrow Waste leaves Bitwick at first light and crosses the dunes for weeks. Its master, Orsa Kell, pays escorts to keep the manifest. Every load lashed to a pack-beast gets a tag naming the day of the crossing it was loaded, how many sacks it holds and what is in them. The tax-posts along the Waste reject any tag not written in the exact form below.

Write caravanTag(goods, day, sacks), where:

  • goods is a string naming the contents. Copy it into the tag exactly as given.
  • day is a non-negative integer.
  • sacks is a non-negative integer.

Return a string of the form:

Day DD: N sacks of GOODS

The parts are filled in as follows:

  • DD is day padded with leading zeros to at least two digits. Day 7 becomes 07 and day 0 becomes 00. A day with three or more digits is written unchanged.
  • N is sacks written plainly, with no padding.
  • The word after N is sack when sacks is exactly 1, and sacks otherwise, including 0.
  • GOODS is goods, unchanged.

The tag contains single spaces exactly where the form shows them. There is no trailing space or punctuation.

  • string formatting
  • Novice

examples

  1. case 1goods of "saffron", day 7, sacks 3"Day 07: 3 sacks of saffron"
  2. case 2goods of "salt", day 12, sacks 1"Day 12: 1 sack of salt"
  3. case 3goods of "glass beads", day 104, sacks 25"Day 104: 25 sacks of glass beads"
reward
120 XP
signature
caravanTag
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…
  • padded day, plural
  • single sack
  • zero day and zero sacks
  • three-digit day unchanged
  • goods copied verbatim with single sack
  • two-digit day no padding
The Salt-Caravan of Dunmarrow Waste · bitwick