-
-
Notifications
You must be signed in to change notification settings - Fork 46.9k
Create collision_between_rectangles.py #7831
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
Conversation
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.
Click here to look at the relevant links ⬇️
🔗 Relevant Links
Repository:
Python:
Automated review generated by algorithms-keeper. If there's any problem regarding this review, please open an issue about it.
algorithms-keeper
commands and options
algorithms-keeper actions can be triggered by commenting on this PR:
@algorithms-keeper review
to trigger the checks for only added pull request files@algorithms-keeper review-all
to trigger the checks for all the pull request files, including the modified files. As we cannot post review comments on lines not part of the diff, this command will post all the messages in one comment.NOTE: Commands are in beta and so this feature is restricted only to a member or owner of the organization.
"width": 30 | ||
} | ||
|
||
def check_collision(rect1, rect2) -> bool: |
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.
Please provide type hint for the parameter: rect1
Please provide type hint for the parameter: rect2
for more information, see https://pre-commit.ci
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.
Click here to look at the relevant links ⬇️
🔗 Relevant Links
Repository:
Python:
Automated review generated by algorithms-keeper. If there's any problem regarding this review, please open an issue about it.
algorithms-keeper
commands and options
algorithms-keeper actions can be triggered by commenting on this PR:
@algorithms-keeper review
to trigger the checks for only added pull request files@algorithms-keeper review-all
to trigger the checks for all the pull request files, including the modified files. As we cannot post review comments on lines not part of the diff, this command will post all the messages in one comment.NOTE: Commands are in beta and so this feature is restricted only to a member or owner of the organization.
rect2 = {"x": 20, "y": 30, "height": 40, "width": 30} | ||
|
||
|
||
def check_collision(rect1, rect2) -> bool: |
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.
Please provide type hint for the parameter: rect1
Please provide type hint for the parameter: rect2
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.
Click here to look at the relevant links ⬇️
🔗 Relevant Links
Repository:
Python:
Automated review generated by algorithms-keeper. If there's any problem regarding this review, please open an issue about it.
algorithms-keeper
commands and options
algorithms-keeper actions can be triggered by commenting on this PR:
@algorithms-keeper review
to trigger the checks for only added pull request files@algorithms-keeper review-all
to trigger the checks for all the pull request files, including the modified files. As we cannot post review comments on lines not part of the diff, this command will post all the messages in one comment.NOTE: Commands are in beta and so this feature is restricted only to a member or owner of the organization.
rect2 = {"x": 20, "y": 30, "height": 40, "width": 30} | ||
|
||
|
||
def check_collision(rect1 -> dict, rect2 -> dict) -> bool: |
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.
An error occured while parsing the file: maths/collision_between_rectangles.py
Traceback (most recent call last):
File "/opt/render/project/src/.venv/lib/python3.10/site-packages/libcst/_parser/base_parser.py", line 151, in _add_token
plan = stack[-1].dfa.transitions[transition]
KeyError: ReservedString(->)
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/opt/render/project/src/algorithms_keeper/parser/python_parser.py", line 145, in parse
reports = lint_file(
libcst._exceptions.ParserSyntaxError: Syntax Error @ 6:27.
Incomplete input. Encountered '->', but expected ')'.
def check_collision(rect1 -> dict, rect2 -> dict) -> bool:
^
rect1 = {"x": 10, "y": 10, "height": 30, "width": 50} | ||
|
||
rect2 = {"x": 20, "y": 30, "height": 40, "width": 30} |
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.
These are not used within the actual code, so it should go within the if __name__ == "__main__"
as test variables
""" | ||
Check if two rectangle are colliding/overlapping | ||
|
||
>>> check_collision(rect1, rect2) |
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.
Test variables should go inside the doctest, not outside
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 dicts for the rectangles? Why not a class? It'd make creating and using the rectangles a lot easier. This feels like it should be part of a much larger shape library than just a single standalone function.
Closing due to inactivity and lack of response to reviews. |
Describe your change:
Added algorithm to check collision between two rectangles
[x] Add an algorithm