diff options
| author | Mohammad S Anwar <Mohammad.Anwar@yahoo.com> | 2022-02-16 10:32:33 +0000 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2022-02-16 10:32:33 +0000 |
| commit | 7c480291e4a71e4320fc98553de21c9eb47058c8 (patch) | |
| tree | 88ec6352c250c5653550dec54fb15984523b022d /challenge-152/abigail/python/ch-1.py | |
| parent | 348df89f110c0cc8654bc7ef97e1960e96c57ef2 (diff) | |
| parent | d6bba8467dbed369a17a8c8924d4cf51de6563b6 (diff) | |
| download | perlweeklychallenge-club-7c480291e4a71e4320fc98553de21c9eb47058c8.tar.gz perlweeklychallenge-club-7c480291e4a71e4320fc98553de21c9eb47058c8.tar.bz2 perlweeklychallenge-club-7c480291e4a71e4320fc98553de21c9eb47058c8.zip | |
Merge pull request #5658 from Abigail/abigail/week-152
Week 152: Solutions in 8 languages.
Diffstat (limited to 'challenge-152/abigail/python/ch-1.py')
| -rw-r--r-- | challenge-152/abigail/python/ch-1.py | 28 |
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) |
