Loading...
Loading...
Loading...
Split a word into pieces so that every piece reads the same forwards and backwards. Print every way, one per line, with pieces separated by a space. A split whose first piece is shorter comes first; if the first pieces are equal, compare the next piece the same way.
Example
Input
aab
Output
a a b aa b
Splits: a a b and aa b.
Try the problem first. Open one hint at a time.
Try every prefix of the remaining text. Only go on when the prefix is a palindrome.
When the start index reaches the end of the word, print the pieces.
Write your Python code, run it on the examples and submit it to hidden tests.
Solve in the editor