Definition of a Wavy Word:
- If you connect with curves all the characters of a Wavy Word on the alphabet (A-Z) you obtain the path of a wave continuously going toward right or toward left and never changing direction, like in the diagrams below.
- A Wavy Word can be:
- Raising if each consecutive character is at the right (on the alphabet) of the previous one.
- Decreasing if each consecutive character is at the left (on the alphabet) of the previous one.
- 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.
- If a word has double characters, like "SPOON", you must collapse the doubles to one character: "SPOON" > "SPON" (because if you go from O to O is zero distance).
- The Wavy Words will contain at least 3 distinct characters (even after doubles collapsing).
Here there are some examples:
Write a full program or function that will take a word from standard input and will output if it is a Wavy Word or not, and in positive case, output if it is raising or decreasing. The output can be
NO/WR/WD, etc, you decide how to represent it.
WAVY WORDS: ADEPT, BEGIN, BILL, BOSS, BOOST, CHIMP, KNOW, SPONGE, SPOON, TROLL, WOLF ADEPT > YES > RAISING BEGIN > YES > RAISING BILL > YES > RAISING BOSS > YES > RAISING BOOST > YES > RAISING CHIMP > YES > RAISING KNOW > YES > RAISING SPONGE > YES > DECREASING SPOON > YES > DECREASING TROLL > YES > DECREASING WOLF > YES > DECREASING NOT WAVY WORDS: WATCH, EARTH, NINON, FOO, BAR, WAVE, SELECTION, YES, NO, DEFINITION, WATER, WINE, CODE, AAAHHHH, I, MM, ABCA
- Shortest code wins.
Find, as a list, as many Wavy Words as you can in an English dictionary, and the longest as well. You can take for example as reference the complete list of English words here.