-
-
Notifications
You must be signed in to change notification settings - Fork 46.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Added doctests for matrix/count_islands_in_matrix.py #12555
base: master
Are you sure you want to change the base?
Conversation
matrix/count_islands_in_matrix.py
Outdated
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]] | ||
""" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hopefully that should be good now. Let me know if there's anything else that needs fixing
def count_islands(self) -> int: # And finally, count all islands. | ||
def count_islands(self) -> int: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not Required initially to define the function
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, removed
# Checking all 8 elements surrounding nth element | ||
""" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why do we need to define the element in the comments when it's already presented?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That should be sorted now
Describe your change:
Related to #9943
Checklist: