‹ back to the board

Monday, November 9

Novicesyntax & basics

The Waystones of the Sallowmere Dunes

The Cistern-Wardens of the Sallowmere Dunes pay well for stonecutters. Across the dunes, every caravan route is marked by numbered waystones, and the sandstorms scour the old carvings away each season. The Wardens have posted a commission: recut every waystone with its number, the name of the place it marks, and how many leagues that place lies from the Bitwick road. Every stone must be carved in exactly the same form, so that riders can read them at a glance through blowing sand.

Write carveWaystone(stone, name, leagues), which returns the inscription for one waystone as a string.

Arguments - stone: a non-negative integer, the waystone's number. - name: a non-empty string, the place the stone marks. Use it exactly as given. - leagues: a non-negative integer, the distance in leagues.

Return a string of exactly this form:

Stone NNN: NAME, D UNIT

  • NNN is stone written with leading zeros so that it is at least 3 digits long. A number that already has 3 or more digits is written in full, with no padding and no truncation.
  • NAME is name, unchanged.
  • D is leagues written as a plain integer, with no padding.
  • UNIT is league when leagues is exactly 1, and leagues otherwise, including when it is 0.

There is exactly one space after the colon, one space after the comma, and one space between D and UNIT. There is no trailing punctuation.

  • string formatting
  • Novice

examples

  1. case 1stone 7, name "Ossery Wells", leagues 12"Stone 007: Ossery Wells, 12 leagues"
  2. case 2stone 1, name "Kettle Rock", leagues 1"Stone 001: Kettle Rock, 1 league"
  3. case 3stone 1204, name "Last Cistern", leagues 310"Stone 1204: Last Cistern, 310 leagues"
reward
130 XP
signature
carveWaystone
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-digit padding with plural
  • singular league
  • zero stone and zero leagues
  • one leading zero
  • four-digit stone not truncated
  • exactly three digits
  • eleven leagues is plural
The Waystones of the Sallowmere Dunes · bitwick