Skip to content

Instantly share code, notes, and snippets.

@dereknheiley
Forked from minichate/palindrome.py
Last active December 24, 2015 01:09
Show Gist options
  • Save dereknheiley/6721122 to your computer and use it in GitHub Desktop.
Save dereknheiley/6721122 to your computer and use it in GitHub Desktop.
def isPalindrome(input_string):
def _string_iterator():
_len = len(input_string)
for i in xrange(_len / 2):
yield input_string[i], input_string[_len - i - 1]
for c1, c2 in _string_iterator():
if c1 != c2:
return False
return True
f = open('terabyteFile.txt')
#http://stackoverflow.com/questions/519633/lazy-method-for-reading-big-file-in-python
def read1k():
return f.read(1024)
print 'testing to see if all the words are palindromes'
for stream in iter(read1k, ''):
if not isPalindrome(stream) :
raise SystemExit('#failwhale: false')
print 'Yo dawg, I hear you like palindromes: true'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment