Refactor 'palindrome partitioning'.