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).
glyphsis a list of strings (possibly empty, and glyph names may repeat).kis an integer with0 <= k <=the length ofglyphs.
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.
examples
- case 1
glyphs of ["sun", "moon", "star", "eye", "key"], k of 2["star", "eye", "key", "sun", "moon"] - case 2
glyphs of ["ox", "hawk", "serpent"], k of 3["ox", "hawk", "serpent"] - a full turn leaves the wheel as it was - case 3
glyphs of [], k of 0[]
- reward
- 140 XP
- signature
turnWheel
TypeScript, run as ES2022 — types are stripped, not checked. If a JS engine would run it, so will we.
- turn of two
- no turn
- full turn
- empty wheel
- single glyph full turn
- turn of one
- repeated glyphs
- turn all but one