A simple script to test if user-supplied text is a palindrome using 3 different methods, ignoring case and any non-letter characters or punctuation. This script uses string substitution with regular expressions to clean text, as well as recursive and iterative versions of the palindrome checking function.
- Python 3
- (Optional) The included test suite (
test.sh
) requires roundup (brew install roundup
for OSX)
Letter casing and punctuation do not matter when testing a palindrome. All of the following are valid palindromes:
- stunt nuts
- Lisa Bonet ate no basil.
- A man, a plan, a cat, a ham, a yak, a yam, a hat, a canal: Panama!
- Doc, note, I dissent. A fast never prevents a fatness. I diet on cod.