palindromes on twitter - rettiwt no semordnilap

posted on January 24, 2010 - tagged as: python

Lately I’ve been thinking about processing streams of data on the fly. Weirdly enough, I have a fascination with palindromes, so I wrote a very bad hack with Twisted to hookup to the streaming twitter feed and search for these things. Over the course of about a day, I found 259 distinct palindromes where palindromes are (very narrowly) defined as:

  1. Words without punctuation, numbers or accents (i.e. only a-z in regex).
  2. Longer than four characters.
  3. Consisting of three or more distinct characters.
  4. Not in a set of stop words I decided I was not interested in.

The astute reader will notice that these rules actual mean all valid palindromes will be 5 or more characters. Now for the results:

Twitter Palindromes

“Level” is the clear winner with 662 occurrences. The venerable palindrome “racecar” sped into the #30 spot with a mere 8 occurrences.

Unfortunately I did not keep track of how many tweets I scanned, but it appears a very small percentage of tweets contain this type of palindrome.  I would like to convert this to a full-on palindrome tracking twitter bot that will annoyingly tweet at you if you tweet something palindrome-ish, but I am slightly afraid someone would take that code and make streaming-twitter-pesterbot-v1™.  Hunting for palindromic sentences would be fun, too (a palindromic 144 character tweet would be pure genius).  Most importantly, I’d like to search for sarahpalindromes which I’ve defined as words that become palindromes with one transposition (sarahpalindrome detection algorithms are much appreciated…you could probably get a paper out of something like that).

Comments !