diff options
| author | David Ferrone <zapwai@gmail.com> | 2024-05-27 00:30:38 -0400 |
|---|---|---|
| committer | David Ferrone <zapwai@gmail.com> | 2024-05-27 00:30:38 -0400 |
| commit | cc7611c673901442ddfac5a71c691350144dcd03 (patch) | |
| tree | 438179ab3f56053f12951d76701b704b4822a323 /challenge-271/zapwai/python/ch-1.py | |
| parent | 5ea56aa37a9f0b7098302e2acb76c73907c70bde (diff) | |
| download | perlweeklychallenge-club-cc7611c673901442ddfac5a71c691350144dcd03.tar.gz perlweeklychallenge-club-cc7611c673901442ddfac5a71c691350144dcd03.tar.bz2 perlweeklychallenge-club-cc7611c673901442ddfac5a71c691350144dcd03.zip | |
Week 271
Diffstat (limited to 'challenge-271/zapwai/python/ch-1.py')
| -rw-r--r-- | challenge-271/zapwai/python/ch-1.py | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/challenge-271/zapwai/python/ch-1.py b/challenge-271/zapwai/python/ch-1.py new file mode 100644 index 0000000000..5cba68f53f --- /dev/null +++ b/challenge-271/zapwai/python/ch-1.py @@ -0,0 +1,32 @@ +def proc(m): + print("Input: m = ", m) + cnt = [] + for i in range(len(m)): + cnt.append(0) + pres = 0 + for row in m: + for entry in row: + if entry == 1: + cnt[pres] += 1 + pres += 1 + max = 0 + max_index = 0 + for i in range(len(cnt)): + if cnt[i] > max : + max_index = i + max = cnt[i] + print( "Output: row", max_index + 1, " ( count is", max, ")") + +matrix = [ [0, 1], + [1, 0], + ] +proc(matrix) +matrix = [ [0, 0, 0], + [1, 0, 1], + ] +proc(matrix) +matrix = [ [0, 0], + [1, 1], + [0, 0], + ] +proc(matrix) |
