Added doctests for matrix/count_islands_in_matrix.py - #12555
Open
CheerfulBear22 wants to merge 6 commits into
Open
CheerfulBear22 wants to merge 6 commits into
CheerfulBear22 wants to merge 6 commits into
Conversation
imSanko
suggested changes
Feb 4, 2025
Comment on lines
6
to
+18
| class Matrix: # Public class to implement a graph | ||
| def __init__(self, row: int, col: int, graph: list[list[bool]]) -> None: | ||
| """ | ||
| Initialise matrix with number of rows, columns, and graph | ||
|
|
||
| >>> m = Matrix(4, 3, [[True, False, False, False], [True, False, True, False], [False, False, True, True]]) | ||
| >>> m.ROW | ||
| 4 | ||
| >>> m.COL | ||
| 3 | ||
| >>> m.graph | ||
| [[True, False, False, False], [True, False, True, False], [False, False, True, True]] | ||
| """ |
Contributor
There was a problem hiding this comment.
Remove the row and col parameters from the Matrix init and instead derive them from the graph's dimensions. This prevents inconsistencies and possible index errors.
Author
There was a problem hiding this comment.
Hopefully that should be good now. Let me know if there's anything else that needs fixing
added 3 commits
February 4, 2025 19:20
imSanko
suggested changes
Feb 5, 2025
Comment on lines
-29
to
+76
| def count_islands(self) -> int: # And finally, count all islands. | ||
| def count_islands(self) -> int: |
Contributor
There was a problem hiding this comment.
Not Required initially to define the function
Comment on lines
-21
to
+54
| # Checking all 8 elements surrounding nth element | ||
| """ |
Contributor
There was a problem hiding this comment.
Why do we need to define the element in the comments when it's already presented?
Author
There was a problem hiding this comment.
That should be sorted now
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Describe your change:
Related to #9943
Checklist: