Background

A Lyndon word is a non-empty string which is strictly lexicographically smaller than all its other rotations. It is possible to factor any string uniquely as the concatenation of Lyndon words such that these subwords are lexicographically non-increasing; your challenge is to do this as succinctly as possible.

Details

You should implement a function or program which enumerates the Lyndon word factorization of any printable ASCII string, in order, outputting the resultant substrings as an array or stream of some kind. Characters should be compared by their code points, and all standard input and output methods are allowed. As usual for , the shortest program in bytes wins.

Test Cases

''           []
'C'          ['C']
'aaaaa'      ['a', 'a', 'a', 'a', 'a']
'K| '        ['K|', ' ']
'abaca'      ['abac', 'a']
'9_-$' ['9_', '-', '$']
'P&O(;'      ['P', '&O(;']
'xhya{Wd$' ['x', 'hy', 'a{', 'Wd', '$']
'jM?LO!!Y'  ['j', '', 'M', '?LO', '!!Y']
'!9!TZ'      ['!9!TZ']
'vMMe'       ['v', 'MMe']
'b5A9A9<5{0' ['b', '5A9A9<5{', '0']

• Related – xnor Jun 19 '17 at 20:49
• Note that this is equivalent to splitting by <=ness. (I have no idea how to express this better :| ) – CalculatorFeline Jun 19 '17 at 21:01
• Is this equivalent to repeatedly taking the first character and the prefix of all characters bigger than it? – xnor Jun 19 '17 at 21:07
• @xnor No. 'abac' is a Lyndon word. – user1502040 Jun 19 '17 at 21:13
• @user1502040 I see, ties are interesting. I'd suggest adding some test cases that catch this. – xnor Jun 19 '17 at 21:14

Pyth, 17 16 bytes

-1 byte thanks to isaacg!

hf!ff>Y>YZUYT+./


Try it online!

Explanation

hf!ff>Y>YZUYT+./
./    Take all possible disjoint substring sets of [the input]
+      plus [the input] itself (for the null string case).
f                  Filter for only those sets which
!f        T       for none of the substrings
f  >YZUY        is there a suffix of the substring
>Y             lexographically smaller than the substring itself.
h                   Return the first (i.e. the shortest) such set of substrings.

• hf!ff>Y>YZUYT+./ accounts for the empty string case with 1 less byte. – isaacg Jun 19 '17 at 22:12
• Nice, thanks! I felt like there must have been a shorter way. – notjagan Jun 19 '17 at 22:15

Jelly, 18 bytes

ṙJ¹ÐṂF⁼
ŒṖÇ€Ạ\$ÐfṀȯ


Try it online!

Pyth - 28 bytes

hf&SI_T.Am.A>Rdt.u.>N1tddT./

• This seems to fail on the empty string. – user1502040 Jun 19 '17 at 21:34