A string is a palindrome if and only if it reads the same forwards and backwards.
A substring of a string
Define a string to be odd if and only if all substrings of the string that are palindromes have odd length.
Given a string
Constraints
Input Specification
The input consists of a single line containing the string
Output Specification
Print on a single line, if the string is odd, Odd
; if not, Even
.
Sample Input 1
Copy
amanaplanacanalpanama
Sample Output 1
Copy
Odd
Sample Input 2
Copy
madamimadam
Sample Output 2
Copy
Odd
Sample Input 3
Copy
annamyfriend
Sample Output 3
Copy
Even
Sample Input 4
Copy
nopalindromes
Sample Output 4
Copy
Odd
Comments
can someone check my code? https://dmoj.ca/submission/6984651
just looked at the top solution and realized I am stupid.
for some reason you need to end your answers with a newline to pass? it does say
so idk
This happens to be a xiaowuc1 problem, which uses an
identical
checker. Standard convention uses a newline at the end of input, which is how the test data is formatted.To my younger students struggling with this question because you are attempting to check if every single substring is a palindrone, and then determining whether it has an even or odd length: I appreciate your tenacity.
There is a reason this is only a 3 point question and is considered "J2 level" as there is a simpler approach which may not be obvious to many of you. After fighting with this problem for a reasonable time, please click on the "Read editorial" link on the right, and read the message from the author for a hint.