diff options
| author | Abigail <abigail@abigail.be> | 2021-01-12 16:58:05 +0100 |
|---|---|---|
| committer | Abigail <abigail@abigail.be> | 2021-01-12 16:58:05 +0100 |
| commit | 9af685c4d60cc554406827da104fc2df5078ae99 (patch) | |
| tree | a488b361745b13a4544fa2c1daa8a7f124ff9028 | |
| parent | 96ef1fe74c42a2f6aa3bf584f8e0d88e4040c4cd (diff) | |
| download | perlweeklychallenge-club-9af685c4d60cc554406827da104fc2df5078ae99.tar.gz perlweeklychallenge-club-9af685c4d60cc554406827da104fc2df5078ae99.tar.bz2 perlweeklychallenge-club-9af685c4d60cc554406827da104fc2df5078ae99.zip | |
Handle Unicode for Python solution, week 95/part 1.
No script runs though.
| -rw-r--r-- | challenge-095/abigail/python/ch-1.py | 13 | ||||
| -rw-r--r-- | challenge-095/abigail/t/ctest.ini | 8 |
2 files changed, 17 insertions, 4 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 diff --git a/challenge-095/abigail/t/ctest.ini b/challenge-095/abigail/t/ctest.ini index b6214f62df..c08015176d 100644 --- a/challenge-095/abigail/t/ctest.ini +++ b/challenge-095/abigail/t/ctest.ini @@ -1,3 +1,7 @@ +#
+# Config file for 'ctest'. See
+# https://github.com/Abigail/Misc/blob/master/ctest
+#
[names]
1-1 = Given examples
1-2 = Test decimal dot
@@ -7,8 +11,8 @@ 2-1 = Given example
2-2 = Test empty stack
-[1-5/node]
+[1-5/node,python]
skip = No script runs assertions available
-[1-4,1-5/c,awk,python]
+[1-4,1-5/c,awk]
skip = No Unicode support
|
