I don't know about you all but I'm not preparing for Halloween––never did never will––but, my neighbor is, so we'll help her out.
She needs help figuring out which brand of candy she has, but she has so much candy she would not be able to finish before Halloween.
She has:
- Snickers
- KitKat
- Starburst
- GummyBears
- Twix
Input
A multiline string (or any other reasonable form) containing only letters and spaces.
Output
A falsy value if it is not a valid candy, or which candy it is if it is a candy.
How to decide which candy it is
A candy is valid if it says one of the above brands on it. However, it's not that simple, because this is a valid candy:
K i t
K a
t
A valid candy is one where:
- the letters are in order from left to right
- the letters are capitalized correctly
- the letters, going from left to right, do not both ascend and descend
- the letters with whitespace removed form one of the above brands
This is code-golf, so shortest code in byte wins!
Examples
Truthys:
1.
kers
c
i
n
S
2.
Kit K a t
3.
St a
r b u
r st
4.
Bear s
G ummy
5.
T w i
x
Falsys:
1.
SNICKERS
2.
C n
a d y
3.
xiwT
4.
S C I
ss o
r s
5.
Kit
Kat