(Note: This is a spin-off of my previous challenge Find the Swirling Words!)
Definition of Infinity Word:
- If you connect with curves all the characters of an Infinity Word on the alphabet (A-Z) you obtain the infinity symbol ∞ like in the diagrams below.
- All the even connection must be down, all the odd connections must be up.
- You can ignore upper/lowercase or consider/convert all to upper case or all to lower case.
- The input words are only characters in the alphabet range of A-Z, no spaces, no punctuation, or symbols.
- Each word must be exactly 5 characters. Words > 5 or < 5 are not valid.
- If a word has double consecutive characters, the word is not valid, like "FLOOD" or "QUEEN".
- All the Infinity Words start and end with the same character.
Here there are some examples:
Task:
Write a full program or function that will take a word from standard input and will output if is an Infinity Word or not. The output can be true/false, 1/0, 1/Null, etc.
Test cases:
Infinity Words:
ALPHA, EAGLE, HARSH, NINON, PINUP, RULER, THEFT, WIDOW
NOT Infinity Words:
CUBIC, ERASE, FLUFF, LABEL, MODEM, RADAR, RIVER, SWISS, TRUST,
KNEES, QUEEN, GROOVE, ONLY, CHARACTER, OFF, IT, ORTHO
Rules:
- Shortest code wins.
Optional Task:
Find, as a list, as many Infinity Words as you can in an English dictionary. You can take for example as reference the complete list of English words here.