aboutsummaryrefslogtreecommitdiff
path: root/challenge-270/zapwai/python
diff options
context:
space:
mode:
authorMohammad Sajid Anwar <Mohammad.Anwar@yahoo.com>2024-05-21 13:43:38 +0100
committerGitHub <noreply@github.com>2024-05-21 13:43:38 +0100
commitc4ae6428a67c4844df2844a8cb39a8bcf705a8aa (patch)
treee5c9d4963cb207141a72fe0daaae4b61dfeb0201 /challenge-270/zapwai/python
parent05dab35c713c1d08a83305d8cdd6e9328d86575a (diff)
parent7543ffc033b251b55c32ce83133b789e520995d6 (diff)
downloadperlweeklychallenge-club-c4ae6428a67c4844df2844a8cb39a8bcf705a8aa.tar.gz
perlweeklychallenge-club-c4ae6428a67c4844df2844a8cb39a8bcf705a8aa.tar.bz2
perlweeklychallenge-club-c4ae6428a67c4844df2844a8cb39a8bcf705a8aa.zip
Merge pull request #10124 from zapwai/branch-for-270
Week 270
Diffstat (limited to 'challenge-270/zapwai/python')
-rw-r--r--challenge-270/zapwai/python/ch-1.py40
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)