diff options
| author | Lubos Kolouch <lubos@kolouch.net> | 2020-08-16 13:54:43 +0200 |
|---|---|---|
| committer | Lubos Kolouch <lubos@kolouch.net> | 2020-08-16 13:54:43 +0200 |
| commit | 8543f8965310f3f234ecf858f1d1f455eff27652 (patch) | |
| tree | e2213f1a42aff4cf16e0bbbe94cb3cff09f7b4e9 /challenge-073 | |
| parent | 3bf5fe8273a629030acc4c819c3f7b7313c7ef44 (diff) | |
| download | perlweeklychallenge-club-8543f8965310f3f234ecf858f1d1f455eff27652.tar.gz perlweeklychallenge-club-8543f8965310f3f234ecf858f1d1f455eff27652.tar.bz2 perlweeklychallenge-club-8543f8965310f3f234ecf858f1d1f455eff27652.zip | |
Python Task 1 LK
Diffstat (limited to 'challenge-073')
| -rwxr-xr-x | challenge-073/lubos-kolouch/python/ch-1.py | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/challenge-073/lubos-kolouch/python/ch-1.py b/challenge-073/lubos-kolouch/python/ch-1.py new file mode 100755 index 0000000000..2202e49cce --- /dev/null +++ b/challenge-073/lubos-kolouch/python/ch-1.py @@ -0,0 +1,27 @@ +#! /usr/bin/env python +""" Perl weekly challenge 073 + https://perlweeklychallenge.org/blog/perl-weekly-challenge-073/ Task 1 """ + + +def min_window(arr, s): + """ Return the min sliding window""" + + return_array = list() + + pos = 0 + + while 1: + last_index = min(len(arr)-1, pos + s) + + app_min = min(arr[pos:last_index]) + return_array.append(app_min) + + if last_index == len(arr)-1: + break + + pos += 1 + + return return_array + + +assert min_window([1, 5, 0, 2, 9, 3, 7, 6, 4, 8], 3) == [0, 0, 0, 2, 3, 3, 4] |
