‹ back to the board

Monday, October 5

Novicesyntax & basics

The Oracle Bones of Quenmoor

The seers of Quenmoor carve each prophecy onto a strip of bone as a line of glyphs. Before the bone leaves the shrine, the seers add warding glyphs to it: the same number at the front as at the back. An adventurer who carries a bone to the far villages must read out only the prophecy between the wards.

Write readProphecy(glyphs, n), where:

  • glyphs is a string, the full line carved on the bone (it may be empty).
  • n is a non-negative integer, the number of warding characters at each end.

Return a string: glyphs with its first n characters and its last n characters removed, with the remaining characters kept in their original order.

If n is 0, return glyphs unchanged. If glyphs has 2 * n characters or fewer, nothing is left between the wards, so return the empty string "".

  • slicing and indexing
  • Novice

examples

  1. case 1glyphs of "##SUNRISE##", n of 2"SUNRISE"
  2. case 2glyphs of "OMEN", n of 0"OMEN" (no wards, nothing removed)
  3. case 3glyphs of "abcd", n of 2"" (the wards cover the whole bone)
reward
140 XP
signature
readProphecy
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 wards each side
  • zero wards keeps everything
  • wards cover the whole bone exactly
  • wards longer than the bone
  • empty bone
  • single ward each side
  • one glyph left in the middle
  • single glyph with zero wards
The Oracle Bones of Quenmoor · bitwick