Skip to content

Commit cf6641e

Browse files
author
Priyal595
committed
Added the doctests - Contributes to #9943
1 parent c79034c commit cf6641e

File tree

2 files changed

+19
-3
lines changed

2 files changed

+19
-3
lines changed

matrix/count_islands_in_matrix.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,20 @@
44

55

66
class Matrix: # Public class to implement a graph
7+
<<<<<<< Updated upstream
8+
=======
9+
"""This public class represents the 2-Dimensional matrix to count
10+
the number of islands.An island is the connected group of 1s,including the top,
11+
down, right, left as well as the diagonal connections.
12+
>>> matrix1 = Matrix(3, 3, [[1, 1, 0], [0, 1, 0], [1, 0, 1]])
13+
>>> matrix1.count_islands()
14+
1
15+
>>> matrix2 = Matrix(2, 2, [[1, 1], [1, 1]])
16+
>>> matrix2.count_islands()
17+
1
18+
"""
19+
20+
>>>>>>> Stashed changes
721
def __init__(self, row: int, col: int, graph: list[list[bool]]) -> None:
822
self.ROW = row
923
self.COL = col

matrix/matrix_class.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -204,9 +204,11 @@ def cofactors(self) -> Matrix:
204204
return Matrix(
205205
[
206206
[
207-
self.minors().rows[row][column]
208-
if (row + column) % 2 == 0
209-
else self.minors().rows[row][column] * -1
207+
(
208+
self.minors().rows[row][column]
209+
if (row + column) % 2 == 0
210+
else self.minors().rows[row][column] * -1
211+
)
210212
for column in range(self.minors().num_columns)
211213
]
212214
for row in range(self.minors().num_rows)

0 commit comments

Comments
 (0)