aboutsummaryrefslogtreecommitdiff
path: root/challenge-126/abigail/python
diff options
context:
space:
mode:
Diffstat (limited to 'challenge-126/abigail/python')
-rw-r--r--challenge-126/abigail/python/ch-1.py24
1 files changed, 24 insertions, 0 deletions
diff --git a/challenge-126/abigail/python/ch-1.py b/challenge-126/abigail/python/ch-1.py
new file mode 100644
index 0000000000..eda639ebdb
--- /dev/null
+++ b/challenge-126/abigail/python/ch-1.py
@@ -0,0 +1,24 @@
+#!/opt/local/bin/python
+
+#
+# See ../README.md
+#
+
+#
+# Run as: python ch-1.py < input-file
+#
+
+import fileinput
+
+for line in fileinput . input ():
+ result = 0
+ seen_one = False
+ for digit in list (line . strip ()):
+ result = result * 9
+ if seen_one:
+ result = result + 8
+ elif digit == "1":
+ seen_one = True
+ elif digit != "0":
+ result = result + int (digit) - 1
+ print (result)