Follow this blog by Email

Friday, 2 August 2013

Find Palindromic sub strings of a string

Here's a good puzzle. Use any programming language to solve it.
Hint: There is faster thing called interpreters, slower ones are compilers.

Input given is a string (character array ) which contains a sequence of individual alphanumeric characters without any spaces, special characters in it.

Find sub-strings of a given string; but those sub-strings should be palindromes.
Print those strings and the total number of such sub strings found.

Note: I put this condition of alphanumeric chars only myself because when I was writing my solution for this problem using python , it has issues in having Non-ASCII characters in some test cases which I constructed to test my python code)

So you guessed my solution which I shall be posting later is in Python.

A palindrome is any number or string which is same if read forward or backwards.
Strings which are palindromes :
   level ;  radar ; SOS ;

No comments: