#C529. Valid Word Checker
Valid Word Checker
Valid Word Checker
Given a word, determine whether it is valid. A word is considered valid if it meets the following conditions:
- It contains only alphabetical letters (both uppercase and lowercase are allowed).
- It does not have three consecutive letters in increasing or decreasing order. In mathematical terms, there should be no indices i such that either $$word[i+1]=word[i]+1\quad\text{and}\quad word[i+2]=word[i]+2$$ or $$word[i+1]=word[i]-1\quad\text{and}\quad word[i+2]=word[i]-2.$$
The input will be read from standard input (stdin) and the output should be printed to standard output (stdout) as either True
or False
based on the validity of the word.
inputFormat
The input consists of a single line containing a string. The string represents the word you need to check.
Example:
ABC
outputFormat
Output a single line: True
if the word is valid, or False
otherwise.
Example:
False## sample
ABC
False