Created
November 12, 2015 06:58
-
-
Save akayj/253006df470b9d0cb574 to your computer and use it in GitHub Desktop.
Palindrome Detect
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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