Your Ad Here

Tag Archive for 'Code'

Processing.js

I have not even had time to play with this yet, but John Resig, creator of the excellent jquery Javascript library, has released Processing.js, a port of Processing to Javascript.

And there was much rejoicing.

Detecting Palindromes With Python, Revisited

I know this is first year computer science stuff, but it can be fun to play with.

Suppose you want a simple, general purpose function to find palindromes. Here’s what I came up with; we’ll name it “ispal.py”:

#!/usr/bin/python
import sys
import re
q = sys.argv[1]
q = re.sub(”(\s+|’|\.|\,|\!|\?|\:|\;)”, “”, q).lower()
print q==q[::-1]

Line by line, it’s pretty simple.
Continue reading ‘Detecting Palindromes With Python, Revisited’


Your Ad Here