fork(3) download
  1. f=lambda s,n=1:s==2*s[:n]or''<s[n:]>-f(s,n+1)<f(s[n:])*f(s[:n])
  2.  
  3. for s in 'aa abaaba bbababbb aabaaababbbaba babababa bbbbbbbbbbbb a ba baab abaabaaba bbbbbbbbbbbbbbb baababbabaaaab aaaaabbaaaaa'.split():
  4. print(repr(f(s)))
Success #stdin #stdout 1.2s 9024KB
stdin
Standard input is empty
stdout
True
True
True
True
True
True
False
False
False
False
False
False
False