aboutsummaryrefslogtreecommitdiff
path: root/challenge-126/abigail/python
diff options
context:
space:
mode:
authorAbigail <abigail@abigail.be>2021-08-20 00:15:30 +0200
committerAbigail <abigail@abigail.be>2021-08-20 00:15:30 +0200
commitceeeb1bec20fca90c87aa2c00ccb30d3cb4ae60b (patch)
tree3a0bf76e4ce852d4d1616cb4cf315a3af3b095d9 /challenge-126/abigail/python
parentd9fbe419a2a4fac19792a9f64d1ffe7cbd7f087e (diff)
downloadperlweeklychallenge-club-ceeeb1bec20fca90c87aa2c00ccb30d3cb4ae60b.tar.gz
perlweeklychallenge-club-ceeeb1bec20fca90c87aa2c00ccb30d3cb4ae60b.tar.bz2
perlweeklychallenge-club-ceeeb1bec20fca90c87aa2c00ccb30d3cb4ae60b.zip
Python solution for week 126, part 1
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)