Submit | All submissions | Best solutions | Back to list |
DNPALIN - Double Near Palindromes |
C-3PO is an expert in pretty much every language. His conversation with R2-D2 are always fun to observe in that R2-D2 speaks in Droid, C-3PO speak in English, and they understand each other perfectly! Anyway, humans and droids both enjoy playing word games. A palindrome is a word or sequence of one or more letters that reads the same forwards and backwards. A near palindrome is a word or sequence that can be changed to or kept a palindrome by changing exactly one letter to a different letter. For example. BAT is a near palindrome, since changing the T to a B would make the word a palindrome: BAB. PEEP is not a near palindrome: although PEEP is palindrome, changing any letter would remove its palindrome status. A double near palindrome is a word or sequence that consist of two near palindromes concatenated together. For example, BATMAN is a double near palindrome, since BAT and MAN are both near palindromes. Given a list of words, you are to determine which words are double near palindromes and which are not.
Input
The input consists of one or more words. All words (except the last) will be inclusively between 1
and 25 letters long and will consist of entirely of capital letters. The last word will be *END* and
is not be processed; it simply indicates the end of the input. There may be any number of spaces
and The output cases are to appear in the same order in which they appear in the input. For each input
case, you are to print either w is a double near palindrome. or w is not a double near
palindrome. whichever is appropriate, where w is the input word. Exactly one Output
Example
Input:
BATMAN
CONSTANTINOPLE
*END*
Output:
BATMAN is a double near palindrome.
CONSTANTINOPLE is not a double near palindrome.
Added by: | Daniel Gómez Didier |
Date: | 2008-11-18 |
Time limit: | 1.200s |
Source limit: | 50000B |
Memory limit: | 1536MB |
Cluster: | Cube (Intel G860) |
Languages: | All except: ERL JS-RHINO NODEJS PERL6 VB.NET |
Resource: | 2007 U.Nacional - Circuito de Maratones ACIS / REDIS |
hide comments
|
|||||
2016-01-25 07:59:10 Projjal Kundu
why is PEEP not a double near palindrome?? PEEP can be broken into PE and EP, in each of them changing one letter would make them palindrome |
|||||
2013-12-25 07:01:53 The_ROCK
" There may be any number of spaces and characters before, after, and between words." here 'characters' means only spaces and newlines and not stray symbols or small letters. |
|||||
2013-08-16 04:14:52 BLANKRK
nice :) |
|||||
2012-07-18 14:01:36 npsabari
O(N^2) dp problem! |
|||||
2012-05-27 17:02:45 Sai Praneeeth
@ Baba Ramdev NO such test cases. Just treat a word in single line to be a single test case. |
|||||
2011-06-12 18:45:44 .::Manish Kumar::.
Can the input be like this too:: BATMANisaassh***CONSTANTIPOLEmm *END* and output should be:: BATMAN is a double near palindrome. CONSTANTINOPLE is not a double near palindrome. |
|||||
2011-05-26 05:26:52 Vladimir Tsibrov
"aa" is a double near palindrome! |
|||||
2010-06-13 13:02:32 hendrik
Watch out! Weird input! The input can be like BATMAN CONSTANTINOPLE *END* And it should still be the same output as above. Whats the point of that? It doesnt make the actual problem harder. Last edit: 2010-06-13 13:30:29 |
|||||
2010-04-26 03:44:13 Ishan
'aa' is it a double near palindrome? |
|||||
2009-06-25 18:15:50 Ankul Garg
c = a[1..m]b[1..n] string b comes after string a, hope u got it Last edit: 2009-06-25 18:16:45 |