Tuesday, October 23, 2007

Problem A (ACM ICPC Philippines 2007)

ACM ICPC Philippines 2007
First Philippine National Inter-Collegiate Programming Competition
20 October 2007, De La Salle Canlubang (Laguna, Philippines)
Organized by the Computing Society of the Philippines (CSP)
in cooperation with the Association for Computing Machinery (ACM)


Problem A: Forward and Backward
( Input File: pa.in )

A palindrome is a word, phrase, number or other sequence of units that has the property of reading the same in either direction. For example, the word tenet and the number 123321 are palindromes.

Palindromes date back at least to 79 A.D., as the palindromic Latin word square "Sator Arepo Tenet Opera Rotas" was found as a graffiti at Herculaneum, buried by ash in that year. This palindrome is remarkable for the fact that it also reproduces itself if one forms a word from the first letters, then the second letters and so forth. Hence it can be arranged into a word square that reads in four different ways: horizontally or vertically from top left to bottom right; and horizontally or vertically from bottom right to top left. (Source: wikipedia.org)

Task: Write a computer program to determine whether a given word or number is a palindrome.

Input: A string of characters (maximum of 255 characters). Note: if a character is a letter, then treat a small letter as equal to a capital letter. For example, the word Tenet is the same as tenet and both words should be treated as palindromes.

Output: For each case, write the capital letter Y if the given string is a palindrome; otherwise, write the capital letter N.

Sample Input:

Tenet
123321
12345678910

Output for the sample input:

Y
Y
N

No comments: