Given an input string S, return
truthy if all the letters in S are Lexically Ordered: their ASCII values need to be in either ascending or descending order. Return
falsy in other cases.
- Input will be in the same case (all upper- or all lowercase). Your submission should be able to handle both.
- Input will consist of ASCII in the range
- Input length will be at least 1, up to whatever maximum your language supports.
- Input is a string - not a list of characters, not an array of ASCII-codepoints.
- Output should be
0/1, or any other distinct
true / falsestyle output your language can provide.
- All true cases need to have the same output, as well as all the false cases. No "False is 0, true is 1, 2, or 3".
- Standard loopholes are forbidden
- Answer must be a full program or a function, not a snippet or a REPL-entry.
- code-golf, shortest answer in bytes wins.
"ABCDEF" "ZYX" "no" "tree" --> the multiple 'e's don't break the order "q"
"ABCDC" "yes" "deed"
"Hello" --> invalid input - mixed case-, does not have to be handled "" --> invalid input - length 0-, does not have to be handled "\n " --> invalid input - newline is not in range [A-Za-z]-, does not have to be handled