‹ back to the board

Tuesday, September 1

Novicesyntax & basics

The Keystone of the Low Arch

The mason rebuilding the low arch by the mill needs one stone finished before the scaffold comes down: the keystone, which by custom carries the middle of the inscription the arch already bears.

You are given runes, a string. Return a string containing the middle of runes:

  • If the length of runes is odd, return the single character at the middle position.
  • If the length of runes is even, return the two characters closest to the middle — that is, the two central characters, in their original order.
  • If runes is empty, return the empty string.

The result is always a string, never a list, and the characters keep the order they had in runes.

  • slicing and indexing
  • Novice

examples

  1. case 1runes of "arch""rc" — four characters, so the two central ones
  2. case 2runes of "stone""o" — five characters, so the single middle one
  3. case 3runes of """" — nothing to carve
reward
140 XP
signature
keystoneRunes
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…
  • odd length picks one character
  • even length picks two characters
  • longer odd inscription
  • longer even inscription
  • single character
  • two characters
  • empty inscription
  • spaces count as characters
The Keystone of the Low Arch · bitwick