43
1
A "simple circular" word is a word whose chords do not intersect. The chords of a word may be seen by laying out the alphabet in a circle, and then connecting the word's consecutive letters.
Examples of Simple Circular Words
ROLE
LAKE
BALMY
Failing Example
A word fails to be simple circular if any of its chords intersect:
The Challenge
Write a program or function that takes a word and returns true if it's simple circular, false otherwise.
- Code golf, fewest bytes wins.
- Standard rules.
- You may assume there are no repeated letters in the word.
- You may assume every word has at least 2 letters
- You may assume the word is all uppercase, or all lowercase, whichever you prefer.
- You may output any two consistent values for true and false.
Test Cases
True
ROLE, LAKE, BALMY, AEBDC, ABZCYDXE, AZL, ZA
False
BONES, ACDB, ALBZ, EGDF
9After around 1 hour of struggling, I've concluded that this cannot be done visually in Scratch. – Lyxal – 2020-01-27T07:41:09.000
4@AZTECCO "You may assume there are no repeated letters in the word." – Kevin Cruijssen – 2020-01-27T08:25:04.250
1@Kevin Cruijssen ah yes, sorry I skipped that. Although this rule makes the challenge simple it's common for words to have repeated letters, plus
ngn
answer seems to work for repeated letters too. Maybe we can have a 2nd challenge later based on this.. – AZTECCO – 2020-01-27T09:41:21.4173@AZTECCO I'll be posting a more difficult sequel to this question later this week. Re: repeated letters specifically, I wanted to avoid dealing with doubles like
GOON
, where the only sensible interpretation is to add a pre-processing step that removes them, which felt uninteresting to me. I'll grant it might have been better to prohibit only contiguous repeats, rather than repeats altogether. – Jonah – 2020-01-27T13:14:18.263