diff options
| author | Mohammad Sajid Anwar <Mohammad.Anwar@yahoo.com> | 2024-05-27 11:52:22 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-05-27 11:52:22 +0100 |
| commit | 7a80978d123027cd31180b1b9300b2a4e04dfada (patch) | |
| tree | fa25c3550b3b050d9ac49f17956db78eb7d8b6c9 /challenge-271/zapwai/python/ch-1.py | |
| parent | 6bdea3bf77857833e97cf55de053444723bb31c6 (diff) | |
| parent | cc7611c673901442ddfac5a71c691350144dcd03 (diff) | |
| download | perlweeklychallenge-club-7a80978d123027cd31180b1b9300b2a4e04dfada.tar.gz perlweeklychallenge-club-7a80978d123027cd31180b1b9300b2a4e04dfada.tar.bz2 perlweeklychallenge-club-7a80978d123027cd31180b1b9300b2a4e04dfada.zip | |
Merge pull request #10157 from zapwai/branch-for-271
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) |
