June 30, 2003 | Category:

Last Palindrome

Ever have one of those zen moments when you see a problem in a perfectly clear way, removing the garbage that you had before? I had one today. It makes my previous effort really quite embarrasing.

I’ve updated the Palindrome code to make it a million times simpler. How did this happen? I was looking at the PHP manual for something entirely unrelated and noticed the strrev function. Everything immediately clicked into place in my head: rather than compare the first and last characters of a string recursively after stripping it down, just strip it down and compare it to its reverse. Simple.

The changes have been uploaded and should have propagated automatically through to the online palindrome checker and XMLRPC API interfaces.