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:
goodsis a string naming the contents. Copy it into the tag exactly as given.dayis a non-negative integer.sacksis 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
daypadded with leading zeros to at least two digits. Day 7 becomes07and day 0 becomes00. A day with three or more digits is written unchanged. - N is
sackswritten plainly, with no padding. - The word after N is
sackwhensacksis exactly 1, andsacksotherwise, including 0. - GOODS is
goods, unchanged.
The tag contains single spaces exactly where the form shows them. There is no trailing space or punctuation.
examples
- case 1
goods of "saffron", day 7, sacks 3"Day 07: 3 sacks of saffron" - case 2
goods of "salt", day 12, sacks 1"Day 12: 1 sack of salt" - case 3
goods of "glass beads", day 104, sacks 25"Day 104: 25 sacks of glass beads"
- reward
- 120 XP
- signature
caravanTag
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