aboutsummaryrefslogtreecommitdiff
path: root/challenge-250/sgreen/python/ch-2.py
diff options
context:
space:
mode:
Diffstat (limited to 'challenge-250/sgreen/python/ch-2.py')
-rwxr-xr-xchallenge-250/sgreen/python/ch-2.py17
1 files changed, 17 insertions, 0 deletions
diff --git a/challenge-250/sgreen/python/ch-2.py b/challenge-250/sgreen/python/ch-2.py
new file mode 100755
index 0000000000..9ee64eea3f
--- /dev/null
+++ b/challenge-250/sgreen/python/ch-2.py
@@ -0,0 +1,17 @@
+#!/usr/bin/env python3
+
+import re
+import sys
+
+
+def calculate_value(s):
+ '''Return the number if it looks like an integer else the length of string'''
+ return int(s) if re.search(r'^\d+$', s) else len(s)
+
+
+def main(values):
+ print(max(map(calculate_value, values)))
+
+
+if __name__ == '__main__':
+ main(sys.argv[1:])