Skip to content

Instantly share code, notes, and snippets.

@akayj
Created November 12, 2015 06:58
Show Gist options
  • Save akayj/253006df470b9d0cb574 to your computer and use it in GitHub Desktop.
Save akayj/253006df470b9d0cb574 to your computer and use it in GitHub Desktop.
Palindrome Detect
#!/usr/bin/env python2
def palindrome(s):
length = len(s)
barrier = length / 2
head2tail = (c for c in s)
tail2head = (s[i] for i in xrange(length-1, -1, -1))
for _ in xrange(barrier):
if head2tail.next() != tail2head.next():
return False
return True
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment