Create collision_between_rectangles.py#7831
Create collision_between_rectangles.py#78310shuvo0 wants to merge 5 commits intoTheAlgorithms:masterfrom
Conversation
There was a problem hiding this comment.
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 reviewto trigger the checks for only added pull request files@algorithms-keeper review-allto 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.
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.
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 reviewto trigger the checks for only added pull request files@algorithms-keeper review-allto 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.
Please provide type hint for the parameter: rect1
Please provide type hint for the parameter: rect2
There was a problem hiding this comment.
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 reviewto trigger the checks for only added pull request files@algorithms-keeper review-allto 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.
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.
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.
Test variables should go inside the doctest, not outside
tianyizheng02
left a comment
There was a problem hiding this comment.
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