A [[palindrome]] is a word or phrase that is spelled the same when it is reversed. Write two functions that test a supplied string to see if it is a palindrome and return a boolean result. Ignore both case and punctuation. Writing a function to remove punctuation and convert to all lowercase would be helpful.
The first function should use recursion by checking the first and last characters to see if they are the same. If they are, pass the string, minus these characters, to the function again. Continue until there is one or no characters left.
The second function should not use recursion but only iteration to compute the same result.
Write a test program to test each function with the following to see if both produce the same results.
- Able was I ere I saw Elba
- A man, a plan, a canal – Panama
- T. Eliot, top bard, notes putrid tang emanating, is sad; I'd assign it a name: gnat dirt upset on drab pot toilet.
- This is not a palindrome!