diff options
| author | David Ferrone <zapwai@gmail.com> | 2024-05-20 13:26:47 -0400 |
|---|---|---|
| committer | David Ferrone <zapwai@gmail.com> | 2024-05-20 13:26:47 -0400 |
| commit | 7543ffc033b251b55c32ce83133b789e520995d6 (patch) | |
| tree | 7abe14ec31968b78c0d6d05b0c892355020ade3b /challenge-270/zapwai/python | |
| parent | ed462bf99ed6fda013ab14d58855951ef13b05fa (diff) | |
| download | perlweeklychallenge-club-7543ffc033b251b55c32ce83133b789e520995d6.tar.gz perlweeklychallenge-club-7543ffc033b251b55c32ce83133b789e520995d6.tar.bz2 perlweeklychallenge-club-7543ffc033b251b55c32ce83133b789e520995d6.zip | |
Week 270
Diffstat (limited to 'challenge-270/zapwai/python')
| -rw-r--r-- | challenge-270/zapwai/python/ch-1.py | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/challenge-270/zapwai/python/ch-1.py b/challenge-270/zapwai/python/ch-1.py new file mode 100644 index 0000000000..cee3a0cdfc --- /dev/null +++ b/challenge-270/zapwai/python/ch-1.py @@ -0,0 +1,40 @@ +matrix = [ [1, 0, 0], + [0, 0, 1], + [1, 0, 0], + ] + +matrix2 = [ [1, 0, 0], + [0, 1, 0], + [0, 0, 1], + ] + +def is_special(m, M, N, i, j): + if m[i][j] != 1: + return 0 + for k in range(M): + if k == i: + continue + if m[k][j] != 0: + return 0 + for k in range (N): + if k == j: + continue + if m[i][k] != 0: + return 0 + return 1 + +def proc(m): + M = len(m) + N = len(m[0]) + print("Input: \nm = ") + cnt = 0 + for i in range(M): + for j in range(N): + print(m[i][j], end='') + if is_special(m, M, N, i, j): + cnt += 1 + print("") + print("Output:", cnt) + +proc(matrix) +proc(matrix2) |
