Skip to content

Add typing to binary_exp_mod.py #9469

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

Merged
merged 3 commits into from
Oct 2, 2023
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion maths/binary_exp_mod.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
def bin_exp_mod(a, n, b):
def bin_exp_mod(a: int, n: float, b: int) -> int:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
def bin_exp_mod(a: int, n: float, b: int) -> int:
def bin_exp_mod(a: int, n: int, b: int) -> int:

n here is actually supposed to be an integer, not a float

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

right that was my first change too, but linter fails on that: 606d844

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe that might be due to the float division / on line 16. Could you try changing that to integer division //?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sure

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@tianyizheng02 thanks this works, also TIL :)
updated similar change on other diff too

"""
>>> bin_exp_mod(3, 4, 5)
1
Expand Down