Canadian Computing Competition: 2016 Stage 1, Junior #3
A palindrome is a word which is the same when read forwards as it is when read backwards. For example,
anna are two palindromes.
A word which has just one letter, such as
a, is also a palindrome.
Given a word, what is the longest palindrome that is contained in the word? That is, what is the longest palindrome that we can obtain, if we are allowed to delete characters from the beginning and/or the end of the string?
The input will consist of one line, containing a sequence of at least ~1~ and at most ~40~ lowercase letters.
Output the total number of letters of the longest palindrome contained in the input word.
Sample Input 1
Output for Sample Input 1
Explanation for Output for Sample Input 1
anana has 5 letters.
Sample Input 2
Output for Sample Input 2
Explanation for Output for Sample Input 2
ada have 3 letters, and there are no other palindromes in the input which are longer.
Sample Input 3
Output for Sample Input 3