fork(4) download
  1. f=lambda s:all((x<y)^(y<z)for x,y,z in zip(s,s[1:],s[2:]))
  2.  
  3. for test in ("ABA","ABB","BAB","BUMP","BALD","BALDY","UPWARD","EXAMINATION","AZBYCXDWEVFUGTHSIRJQKPLOMN","AAA","BBA","ACE","THE","BUMPY","BALDING","ABCDEFGHIJKLMNOPQRSTUVWXYZ"):
  4. print test, '-->', f(test)
Success #stdin #stdout 0s 9024KB
stdin
Standard input is empty
stdout
ABA --> True
ABB --> True
BAB --> True
BUMP --> True
BALD --> True
BALDY --> True
UPWARD --> True
EXAMINATION --> True
AZBYCXDWEVFUGTHSIRJQKPLOMN --> True
AAA --> False
BBA --> False
ACE --> False
THE --> False
BUMPY --> False
BALDING --> False
ABCDEFGHIJKLMNOPQRSTUVWXYZ --> False