Skip to content

Instantly share code, notes, and snippets.

@alenbasic
Created February 9, 2013 00:57
Show Gist options
  • Save alenbasic/4743285 to your computer and use it in GitHub Desktop.
Save alenbasic/4743285 to your computer and use it in GitHub Desktop.
List of palindromes based on the words file in *nix systems.
a = []
b = []
i = 0
z = 0
for line in open('/usr/share/dict/words', 'r').readlines():
while i < len(line)-2:
a.append(line[i])
i = i + 1
while i > 0:
b.append(line[i])
i = i - 1
if a == b and len(a) >= 1:
print line,
z = z + 1
a = []
b = []
print "There are %d palindromes!" % z
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment