The Chalk Rings of the Ossary Conclave
The summoners of the Ossary Conclave draw their binding rings in chalk, one glyph after another, before anything is called up out of the dark. A ring drawn wrong does not hold. The Conclave pays a steady fee to any adventurer who will inspect a ring and pronounce a verdict before the first word of summoning is spoken.
A ring is given as a string, circle. Each character is one glyph, in the order it was drawn.
Write inspectRing(circle), which returns a string verdict. Apply these checks in this order and return the verdict of the first one that applies:
1. If circle is the empty string, return "blank". 2. If any character of circle is not an uppercase English letter A–Z, return "smudged". Lowercase letters, digits, spaces, punctuation and every other character count as not uppercase letters. 3. If the first character is not the same as the last character, return "unclosed". A ring of one character has the same first and last character. 4. If the same character appears three or more times consecutively anywhere in circle, return "overdrawn". Runs are read left to right along the string only; the last character does not join back onto the first. 5. Otherwise, return "sound".
The return value is always exactly one of "blank", "smudged", "unclosed", "overdrawn" or "sound".
examples
- case 1
circle of "ABBBA""overdrawn" - the ends match, but B is drawn three times in a row - case 2
circle of "AB1""smudged" - the ends also differ, but the smudge check comes first - case 3
circle of "Q""sound" - a single glyph starts and ends on the same mark - case 4
circle of "ABBABBA""sound" - no glyph appears more than twice in a row
- reward
- 220 XP
- signature
inspectRing
TypeScript, run as ES2022 — types are stripped, not checked. If a JS engine would run it, so will we.
- empty ring is blank
- single glyph is sound
- simple closed ring is sound
- lowercase glyph is smudged
- space is smudged
- smudge outranks unclosed
- all lowercase is smudged
- mismatched ends are unclosed
- unclosed outranks overdrawn
- triple in the middle
- triple at the start
- triple at the very end
- exactly three glyphs all same
- two of a kind is sound
- separate pairs do not add up
- no wrap-around at the join