‹ back to the board

Wednesday, November 4

Novicesyntax & basics

The Glyph-Wheel of Tessaly Gorge

High above Tessaly Gorge, the cliff-shrine of the Pathwardens bars the only bridge across with a great stone wheel of carved glyphs. The wardens write the wheel down as a list of glyph names, read from the top notch around the rim. A seeker who turns the wheel k notches sends the first k glyphs to the back of the list, in the order they were in. The Pathwardens offer a bounty to whoever can tell them what the wheel reads after any turn.

Write turnWheel(glyphs, k).

  • glyphs is a list of strings (possibly empty, and glyph names may repeat).
  • k is an integer with 0 <= k <= the length of glyphs.

Return a new list made of the elements of glyphs from index k to the end, followed by the elements from index 0 up to but not including index k. Each of those two parts keeps its original order.

  • slicing and indexing
  • Novice

examples

  1. case 1glyphs of ["sun", "moon", "star", "eye", "key"], k of 2["star", "eye", "key", "sun", "moon"]
  2. case 2glyphs of ["ox", "hawk", "serpent"], k of 3["ox", "hawk", "serpent"] - a full turn leaves the wheel as it was
  3. case 3glyphs of [], k of 0[]
reward
140 XP
signature
turnWheel
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…
  • turn of two
  • no turn
  • full turn
  • empty wheel
  • single glyph full turn
  • turn of one
  • repeated glyphs
  • turn all but one
The Glyph-Wheel of Tessaly Gorge · bitwick