Skip to content

Instantly share code, notes, and snippets.

@letoh
Created March 13, 2014 03:14
Show Gist options
  • Select an option

  • Save letoh/9521351 to your computer and use it in GitHub Desktop.

Select an option

Save letoh/9521351 to your computer and use it in GitHub Desktop.
Palindrome
palindrome = lambda s: s[len(s)/2:][::-1].find(s[:len(s)/2])!=-1
palindrome = lambda s: s[len(s)/2:][::-1].startswith(s[:len(s)/2])
palindrome = lambda s: reduce(lambda a,b: a and (b[0]==b[1]), zip(s,s[::-1]), True)
palindrome = lambda s: reduce(lambda a,b:a and b,map(lambda x:x[0]==x[1],zip(s,s[::-1])))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment