aboutsummaryrefslogtreecommitdiff
path: root/challenge-152/abigail/python/ch-1.py
diff options
context:
space:
mode:
authordrbaggy <js5@sanger.ac.uk>2022-02-17 01:16:07 +0000
committerdrbaggy <js5@sanger.ac.uk>2022-02-17 01:16:07 +0000
commit32bf1349de3436301ed753dc24ae0652b3cded26 (patch)
tree40a8ce975c9dba0aaef8f8d8e8475a4ccfcde75d /challenge-152/abigail/python/ch-1.py
parenta49da719c0b0a3580168798f7785eb814378e226 (diff)
parent82393908f2bf4dd4f5a35f2b6b2c7892611fec9a (diff)
downloadperlweeklychallenge-club-32bf1349de3436301ed753dc24ae0652b3cded26.tar.gz
perlweeklychallenge-club-32bf1349de3436301ed753dc24ae0652b3cded26.tar.bz2
perlweeklychallenge-club-32bf1349de3436301ed753dc24ae0652b3cded26.zip
Merge remote-tracking branch 'upstream/master'
Diffstat (limited to 'challenge-152/abigail/python/ch-1.py')
-rw-r--r--challenge-152/abigail/python/ch-1.py28
1 files changed, 28 insertions, 0 deletions
diff --git a/challenge-152/abigail/python/ch-1.py b/challenge-152/abigail/python/ch-1.py
new file mode 100644
index 0000000000..c9062f3070
--- /dev/null
+++ b/challenge-152/abigail/python/ch-1.py
@@ -0,0 +1,28 @@
+#!/usr/local/bin/python3
+
+#
+# See https://theweeklychallenge.org/blog/perl-weekly-challenge-152
+#
+
+#
+# Run as: python ch-1.py < input-file
+#
+
+import fileinput
+
+for line in fileinput . input ():
+ minsum = 0
+ n = 1
+ m = n
+ min = 0
+ for num in line . strip () . split (" "):
+ num = int (num)
+ if n == m or num < min:
+ min = num
+ m = m - 1
+ if m == 0:
+ n = n + 1
+ m = n
+ minsum = minsum + min
+ min = 0
+ print (minsum)