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:
glyphsis a string, the full line carved on the bone (it may be empty).nis 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 "".
examples
- case 1
glyphs of "##SUNRISE##", n of 2"SUNRISE" - case 2
glyphs of "OMEN", n of 0"OMEN" (no wards, nothing removed) - case 3
glyphs of "abcd", n of 2"" (the wards cover the whole bone)
- reward
- 140 XP
- signature
readProphecy
TypeScript, run as ES2022 — types are stripped, not checked. If a JS engine would run it, so will we.
- 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