Most Mirrored Pieces
Cut text into k pieces, each at least one letter long, so that the pieces match from the outside in: the first piece equals the last one, the second equals the second to last, and so on. With an odd k the middle piece is on its own.
Return the largest k that is possible. Leaving text in one piece always works, so the answer is at least 1.
Example 1
text "gonexnego"
returns 5
The pieces are (go)(ne)(x)(ne)(go).
Example 2
text "planet"
returns 1
No start of the text matches an end of it, so it stays in one piece.
Constraints
1 <= len(text) <= 60textholds lowercase letters
Write it in your browser, against the clock. The model solution, stepped through line by line, comes after.