-
-
Notifications
You must be signed in to change notification settings - Fork 46.7k
Fully refactored the rod cutting module. #1169
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
|
||
def rod_cutting(prices: List[int],length: int) -> 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.
A List[int] is more strict than a list of anything.
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.
Making a list[int]
is too restrictive since the prices can be floats
as well.
You can also have mixed prices like [1, 1.2, 3]
.
If values which do not work well with addition
are provided, then a ValueError will be thrown. That's something a user should handle, I think.
Edit: Also, the return type can be float
or int
depending on the prices.
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.
Making a
list[int]
is too restrictive since the prices can befloats
as well.
You can also have mixed prices like[1, 1.2, 3]
.If values which do not work well with
addition
are provided, then a ValueError will be thrown. That's something a user should handle, I think.Edit: Also, the return type can be
float
orint
depending on the prices.
@cclauss, do you insist that I enforced the values of the prices to be integers?
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.
Nope. I am fine with supporting both int and float
This reverts commit 2dfe01e.
* changing typo * fully refactored the rod-cutting module * more documentations * rewording
No description provided.