aboutsummaryrefslogtreecommitdiff
path: root/challenge-095/abigail/python/ch-1.py
diff options
context:
space:
mode:
Diffstat (limited to 'challenge-095/abigail/python/ch-1.py')
-rw-r--r--challenge-095/abigail/python/ch-1.py13
1 files changed, 11 insertions, 2 deletions
diff --git a/challenge-095/abigail/python/ch-1.py b/challenge-095/abigail/python/ch-1.py
index 5378ca65f6..baadd38de4 100644
--- a/challenge-095/abigail/python/ch-1.py
+++ b/challenge-095/abigail/python/ch-1.py
@@ -2,8 +2,17 @@ import fileinput
import re
for line in fileinput . input ():
- line = line . rstrip ()
- if (re . match (r'^\d+(\.\d+)?$', line) and line == line [::-1]):
+ #
+ # Make sure the string is in UTF-8, and remove any newlines
+ #
+ line = line . decode ("utf-8") . strip ()
+
+ #
+ # Should look like an unsigned number (possible decimal)
+ # and be a palindrome.
+ #
+ if (re . match (r'^\d+(\.\d+)?$', line, re . UNICODE) and
+ line == line [::-1]):
print 1
else:
print 0