4 Fixed a typo.
source | link

Python 2: 49 (without counting the method signature)

def f(s):
 s=filter(str.isalnum,s.upper())
 return s==s[::-1]

A complete program, with input and output can be writte in 74 characters.

import sys
s=filter(str.isalnum,sys.stdin.read().upper())
print s==s[::-1]

Example usage:

$echo 'Eva,can I stab bats in a cave?' | python palindrome.py
True 
$ cat huge_palindrome.txt | python palindrome.py
True
$echo 'Able was I ere i SaW elBa' | python palindrome.py                                                                   
True                                         

(huge_palindrome.txt contains this 17,826 word palindrome)

This solution can be adapted to python 3 adding some characters:

Python 3: 55

def f(s):
 s=list(filter(str.isalnum,s.upper()))
 return s==s[::-1]

Python 2: 49 (without counting the method signature)

def f(s):
 s=filter(str.isalnum,s.upper())
 return s==s[::-1]

A complete program, with input and output can be writte in 74 characters.

import sys
s=filter(str.isalnum,sys.read().upper())
print s==s[::-1]

Example usage:

$echo 'Eva,can I stab bats in a cave?' | python palindrome.py
True 
$ cat huge_palindrome.txt | python palindrome.py
True
$echo 'Able was I ere i SaW elBa' | python palindrome.py                                                                   
True                                         

(huge_palindrome.txt contains this 17,826 word palindrome)

This solution can be adapted to python 3 adding some characters:

Python 3: 55

def f(s):
 s=list(filter(str.isalnum,s.upper()))
 return s==s[::-1]

Python 2: 49 (without counting the method signature)

def f(s):
 s=filter(str.isalnum,s.upper())
 return s==s[::-1]

A complete program, with input and output can be writte in 74 characters.

import sys
s=filter(str.isalnum,sys.stdin.read().upper())
print s==s[::-1]

Example usage:

$echo 'Eva,can I stab bats in a cave?' | python palindrome.py
True 
$ cat huge_palindrome.txt | python palindrome.py
True
$echo 'Able was I ere i SaW elBa' | python palindrome.py                                                                   
True                                         

(huge_palindrome.txt contains this 17,826 word palindrome)

This solution can be adapted to python 3 adding some characters:

Python 3: 55

def f(s):
 s=list(filter(str.isalnum,s.upper()))
 return s==s[::-1]
3 added 441 characters in body
source | link

Python 2: 49 (without counting the method signature)

def f(s):
 s=filter(str.isalnum,s.upper())
 return s==s[::-1]

A complete program, with input and output can be writte in 74 characters.

import sys
s=filter(str.isalnum,sys.read().upper())
print s==s[::-1]

Example usage:

$echo 'Eva,can I stab bats in a cave?' | python palindrome.py
True 
$ cat huge_palindrome.txt | python palindrome.py
True
$echo 'Able was I ere i SaW elBa' | python palindrome.py                                                                   
True                                         

(huge_palindrome.txt contains this 17,826 word palindrome)

This solution can be adapted to python 3 adding some characters:

Python 3: 55

def f(s):
 s=list(filter(str.isalnum,s.upper()))
 return s==s[::-1]

Python 2: 49 (without counting the method signature)

def f(s):
 s=filter(str.isalnum,s.upper())
 return s==s[::-1]

A complete program, with input and output can be writte in 74 characters.

import sys
s=filter(str.isalnum,sys.read().upper())
print s==s[::-1]

This solution can be adapted to python 3 adding some characters:

Python 3: 55

def f(s):
 s=list(filter(str.isalnum,s.upper()))
 return s==s[::-1]

Python 2: 49 (without counting the method signature)

def f(s):
 s=filter(str.isalnum,s.upper())
 return s==s[::-1]

A complete program, with input and output can be writte in 74 characters.

import sys
s=filter(str.isalnum,sys.read().upper())
print s==s[::-1]

Example usage:

$echo 'Eva,can I stab bats in a cave?' | python palindrome.py
True 
$ cat huge_palindrome.txt | python palindrome.py
True
$echo 'Able was I ere i SaW elBa' | python palindrome.py                                                                   
True                                         

(huge_palindrome.txt contains this 17,826 word palindrome)

This solution can be adapted to python 3 adding some characters:

Python 3: 55

def f(s):
 s=list(filter(str.isalnum,s.upper()))
 return s==s[::-1]
2 deleted 3 characters in body
source | link

Python 2: 49 (without counting the method signature)

def f(s):
 s=filter(str.isalnum,s.upper())
 return s==s[::-1]

A complete program, with input and output can be writte in 74 characters.

import sys
s=filter(str.isalnum,sys.read().upper())
print s==s[::-1]

This solution can be adapted to python 3 adding some characters:

Python 3: 5855

def f(s):
 s=''.joins=list(filter(str.isalnum,s.upper()))
 return s==s[::-1]

Python 2: 49 (without counting the method signature)

def f(s):
 s=filter(str.isalnum,s.upper())
 return s==s[::-1]

A complete program, with input and output can be writte in 74 characters.

import sys
s=filter(str.isalnum,sys.read().upper())
print s==s[::-1]

This solution can be adapted to python 3 adding some characters:

Python 3: 58

def f(s):
 s=''.join(filter(str.isalnum,s.upper()))
 return s==s[::-1]

Python 2: 49 (without counting the method signature)

def f(s):
 s=filter(str.isalnum,s.upper())
 return s==s[::-1]

A complete program, with input and output can be writte in 74 characters.

import sys
s=filter(str.isalnum,sys.read().upper())
print s==s[::-1]

This solution can be adapted to python 3 adding some characters:

Python 3: 55

def f(s):
 s=list(filter(str.isalnum,s.upper()))
 return s==s[::-1]
1
source | link